Hello, Fallentine.
This code works:
Code:
pause 500
serout s_out, i9600,[0, 7, "Getting Started", 13, 13]
pause 100
cbot var byte
cbot2 var word
main
serin s_in, i9600,[cbot]
if (cbot = "<") then
serout s_out, i9600,["Go Left", 13]
elseif (cbot = ">")
serout s_out, i9600,["Go Right", 13]
elseif (cbot = "X") OR (cbot = "x")
serout s_out, i9600,["STOP!", 13]
elseif (cbot = "^")
serout s_out, i9600,["Go Forward", 13]
elseif (cbot = "r") OR (cbot = "R")
serout s_out, i9600,["Go Reverse", 13]
endif
goto main
You don't want the "str" in your input, it stops proper operation. I got rid of the "goto main"s in your IF-THEN-ENDIF statements. If you don't use the "endif", ie, if the "goto main" breaks the routine before the "endif", then the stack gets filled and wierd <!> happens, maybe even a reset.
So, as you enter characters, a legal character produces its assigned string and does a carriage return. Any other character gets printed to the screen because I'm using the programming port and we have the "loopback" because both the TxD and RxD are sent to a single pin.
As you can see, using "OR" allows you to specify both the uppercase and lowercase of the same letter. Or two different entries if needed.
As for P2 and P5, these are the recieve and transmit pins, respectively, of the builtin hardware USART. These use the HSERxxx commands to operate. These have sizable character buffers. These have interrupts available, but I can't say if these are supported in the BASIC natively, you'll probably have to use the ISRASM function. These are largely set and forget. So, send a character to be transmitted, then jump immediately to another task while the hardware deals with transmitting the character out. Same for the receiver, just do other things 'til the character is fully received. If you have serial streams to handle and a lot of work going on in the background that can't be easily dropped to handle bitbang serial traffic, then the USART is definitely the way to go.
Strange thing about my PC: My Studio terminals don't start reliably. I usually start with Terminal1 at the screen's bottom. Sometimes I'm forced to go to Terminal2 to see things run. Then I'll change code and 1 may work, but maybe not. One time I was forced to use Terminal3 because -1 and -2 wouldn't start?!
So let me know how this works for you.