I was helping a student with a program to control a tri-color LED, when I ran across some unexpected behavior. The issue is that SERRXD turns pin C.5 on the 20M2 to an input. This was confusing, since in this program, pin C.5 is already being used as an output. My understanding from the manual and my own experience is that SERRXD takes input from the serial pin (pin #2 of 20), and should not be affecting of the general I/O pins. SERIN should be used for serial I/O on the general pins.
So can someone explain what is going on? For reference, here is the code. It is controlled via the PC serial terminal window. The program works exactly as expected for the RedLED and BlueLED, but the GreenLED on C.5 turns off as soon as the SERRXD command is re-issued.
Thanks in advance for any advice on this issue.
So can someone explain what is going on? For reference, here is the code. It is controlled via the PC serial terminal window. The program works exactly as expected for the RedLED and BlueLED, but the GreenLED on C.5 turns off as soon as the SERRXD command is re-issued.
Thanks in advance for any advice on this issue.
Code:
symbol Color=b0
symbol RedLED=C.3
symbol GreenLED=C.5
symbol BlueLED=C.2
init:
sertxd("type (r)ed, (g)reen, (b)lue re(c)nnect,")
main:
serrxd[1000, main], Color
if Color="R" or Color="r" then
sertxd ("Red ")
high RedLED
low BlueLED
low GreenLED
elseif Color= "G" or Color= "g" then
sertxd("Green ")
high GreenLED
low RedLED
low BlueLED
elseif Color= "B" or Color= "b" then
sertxd("Blue ")
high BlueLED
low RedLED
low GreenLED
elseif Color= "C" or Color= "c" then
sertxd("Stopping and Reconnecting")
low BlueLED
low RedLED
low GreenLED
reconnect
end
endif
pause 2000
goto main
Last edited: