Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
I don't know if picbasic accepts this code or not, but if you run it like that you wont see the leds do anything. They will light and go out before you even notice...
anyway, if picbasic does accept this code it will be inefficient anyway. Try shifting the bits in port B for better code.
loke this
TRISB = 0
N var byte
PORTB = 1 'light the first led
for N = 0 to 7
'if you want to see it all happen , put a pause here (pause 500 for half a sec)
PORTB = PORTB << 1 'shift the bits in portB left
Next N
i understand what you mean by the LED's lighting too fast then turning off. it was just an example i made up, the important part is using the variable N for a pin number.
If N=1 then your program will write %00000010 to portb.Or if N=2 Portb = %00000100, etc.Wouldn't just putting n into portb(portb=n) have the same result?
To anser your question NO :?
Those identifiers can't work like that bummer. I wanted to do that but that doesn't work.
Depending on what you want to do you ca work around that.
Like in your example you would be better off writting the number to the Port, and then incrementing the a counter variable. In other cases you may want to define arrays and modify those identifiers..... 8)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.