Posted: 06:50am 13 Jul 2011 |
Copy link to clipboard |
Print this post |
|
A slight change to the program so it shows the current state on the terminal....
here is a simple snippet of code to do as requested:
10 status = 1 'intialise the status variable
20 pin(1) = 1 'set pin 1 to be high intially
30 pin(2) = 0 'set pin 2 to be low intially
40 pin(3) = 0 'set pin 3 to be low intially
50 setpin 1,8 'set pin 1 for digital output
60 setpin 2,8 'set pin 2 for digital output
70 setpin 3,8 'set pin 3 for digital output
80 cls:print "Enter y or CNTL-C to stop the program "
85 print:print "State: "; status;
90 settick 15000, 1000 'set tick interrupt for every 15 seconds
98 'loop here forever (or until CNTL-C or 'y'
99 ' entered on the keyboard/USB terminal)
100 do
110 c$ = inkey$
120 if c$ = "y" or c$ = "Y" then 200
130 loop
200 end
998 'settick interrupt routine
999 ' update the pin values and the status variable
1000 if status = 1 then
1010 pin(1) = 0 : pin(2) = 1 : status = 2
1020 locate 42,24:print status;
1030 elseif status = 2 then
1040 pin(2) = 0 : pin(3) = 1 : status = 3
1050 locate 42,24:print status;
1060 elseif status = 3 then
1070 pin(3) = 0 : pin(1) = 1 : status = 1
1080 locate 42,24:print status;
1090 endif
1100 ireturn 'return from the settick interrupt routine
regards
GerardEdited by seco61 2011-07-14
Regards
Gerard (vk3cg/vk3grs) |