Grant Fleming
Senior Member
I have been trying to receive a number from the PICAXE 40X1 into my PC using com port and a Liberty BASIC programme I am writing.
As a test - the number is received ok using the Prog Ed terminal, (I am not using CR or LF).
I want to read and assign a variable in Liberty BASIC to this received number from the PICAXE - I am just getting zero displayed all the time. Is this my confusion over strings, number/variables?
I am successful with sending from PC to PICAXE.
I have done many searches on this forum (found some useful snippets of code) and Liberty BASIC forum, but not finding exactly what I need.
Cheers,
Grant
As a test - the number is received ok using the Prog Ed terminal, (I am not using CR or LF).
I want to read and assign a variable in Liberty BASIC to this received number from the PICAXE - I am just getting zero displayed all the time. Is this my confusion over strings, number/variables?
I am successful with sending from PC to PICAXE.
Code:
'PICAXE code:
talk:
wait 2
readadc10 0,w1 'read potentiomter into PICAXE
w2 = w1/10
sertxd (#w2) 'send pot. reading to LibertyBASIC prog (no cr,lf)
wait 2
serrxd [1000, timeout],b1 'receive user commands from LibertyBASIC
choose: 'choose an action to operate relays
if b1 = 0 then open
if b1 = 1 then close
if b1 = 2 then still
goto talk
open: 'open valve
high 3
low 4
goto talk
close: 'close valve
low 3
high 4
goto talk
still: 'stop valve
low 3
low 4
goto talk
timeout:
goto talk
'Liberty BASIC code (partial only):
[readvvpos]
open "COM3:4800,N,8,1,cs0,ds0,rs" for random as #comm
[repeat]
timer 50, [delay]
wait
[delay]
timer 0
dataRead$ = input$(#comm, lof(#comm))
if dataRead$ = "" goto [repeat]
close #comm
print dataRead$ ' here is where I am fumbling around (for hours)!
dataRead$ = b$
print val(b$)
Cheers,
Grant