Hi all,
I’m experimenting with the serial port of my botboard using the ATOM 28 pro.
I want to be able to update some variables in the ATOM using my PC. I have my botboard connected to the PC using a standard serial cable. Sending data from the ATOM to the PC works fine and also receiving one byte from the PC to the ATOM isn’t a problem. But what I really want to do is sending something like “X100 Y25†to the ATOM.
I wrote something like this:
'Inputs
butA var bit
butB var bit
butC var bit
prev_butA var bit
prev_butB var bit
prev_butC var bit
BUTTON_DOWN con 0
BUTTON_UP con 1
'Variables
ReceiveBuf var byte
Parameter var byte
X var byte
Y var byte
X=0
Y=0
'---------------------------------------------------
main:
'Check Parameters X and Y
'Button A
IF (butA = BUTTON_DOWN) AND (prev_butA = BUTTON_UP) then
serout S_OUT, i19200, "X=",dec X," Y=",dec Y,13]
ENDIF
'Receive data
serin S_IN, i19200, 500, timeout, [ReceiveBuf]
sound p9, [50\2250] 'Data received
'Check parameter
IF(ReceiveBuf="x" | ReceiveBuf="X") THEN
Parameter="x"
ENDIF
IF(ReceiveBuf="y" | ReceiveBuf="Y") THEN
Parameter="y"
ENDIF
'Change value of the selected parameter
IF(ReceiveBuf>="0" & ReceiveBuf<="9") THEN
IF(Parameter="x") THEN
X=1
ENDIF
IF(Parameter="y") THEN
Y=2
ENDIF
ENDIF
timeout 'No input
gosub ReadButtons
goto main
'---------------------------------------------------
ReadButtons:
'Sub for reading the status of the buttons
input P4
input P5
input P6
prev_butA = butA
prev_butB = butB
prev_butC = butC
butA = IN4
butB = IN5
butC = IN6
return
'---------------------------------------------------
And of course…
this doesn’t work
I found some examples but they all wait for input. What I need is a sub routine that checks for input every loop and continues running even without new input. Is this possible or do I need some kind of hardware buffer for this?
Can somebody tell me what I’m doing wrong??
Or where I can find some example.
Thanks
Xan