Hi Savnik,
in your code do this, put your code into nice little chunks that you can see what they do. Chunk1 put all your defines and variable declarations.
chunk 2 is start directory. chunk 3 is main loop. this will help you stay organised.In the start subdirectory give your variables a set value,
I think this should help.
Code:
CMCON = 7
ANSEL = 0
adcon.1 = 7
new var byte
led1 var PORTA.2
led2 var PORTA.3
Start:
led1 = 0
led2 = 0
main:
new = 0
serout porta.0, T9600, ["Enter which LED to light ", 10, 13]
serin porta.1, T9600, new
serout porta.0, T9600, ["LED Chosen: ", new, 10, 13]
if new = "1" then
if led1 = 1 then
led1 = 0
else
led1 = 1
endif
endif
if new = "2" then
if led2 = 1 then
led2 = 0
else
led2 = 1
endif
endif
if new = "0" then
low led1 : low led2
endif
goto main
The commands in the start directory will run only once at startup and should set both leds in the off condition.
Bookmarks