Ricardoco
New Member
ok the dunce is back, and i just cant seem to get things right so if someone could look at this simple piece of code and tell me why it wont work it would be real nice (simple to you maybe) im taking things real easy and well it compiles but it dosnt work so it must be my understanding is wrong so if you could point me in the right direction there as well it would also be nice :roll:
symbol BUTUP = PORTA.0
symbol BUTDN = PORTA.1
BUTVAL Var byte
BUTUP = 0
BUTDN = 0
BUTVAL = 0
TRISA = $FF
TRISB = $00
PORTB = $00
Main:
if BUTUP = 1 THEN BUTVAL = butval +1
IF BUTVAL > 6 THEN BUTVAL = 6
if BUTDN = 1 THEN BUTVAL = butval -1
IF BUTVAL < 0 THEN BUTVAL = 0
Ledson
Ledson:
if BUTVAL > 0 THEN PORTB.0 = 1
if BUTVAL >= 1 THEN PORTB.1 = 1
if BUTVAL >= 2 THEN PORTB.2 = 1
if BUTVAL >= 3 THEN PORTB.3 = 1
if BUTVAL >= 4 THEN PORTB.4 = 1
if BUTVAL = 5 THEN PORTB.5 = 1
if butval = 0 THEN PORTB = 0
Goto Main
end