-->
Page 1 of 1

valu= io(pi,pin)

PostPosted: Sat Feb 24, 2018 6:01 pm
by msvb100
hi Guys
I've been working with ESPBasic for a few days now.
But unfortunately I can not continue.
I want to set a pin high or low and then read it out immediately.
Unfortunately, it does not work.
Valu always stays 0
Also, the attempt to outsource the routine is reported with syntax error.
Would be nice if someone could help me.
Hopefully you can read this text.
He was translated with Google.
Thank you.
Michael S.




Version 1

let valu=99
cls
button "On",[on]
button "Off",[off]
button "Exit",[Exit]
pin= D1


[on]
io(po,pin,1)
valu= io(pi,pin)
print valu
wait


[off]
io(po,pin,0)
valu= io(pi,pin)
print valu
wait

[print]
print valu
wait

[Exit]
wprint |<a href="./edit"> Edit</a>|
end
---------------------------------------------------------------------------------------------------------
Version 2 (Function outsourced....Syntax error)

let valu=99
cls
button "On",[on]
button "Off",[off]
button "Exit",[Exit]
pin= D1

[on]
io(po,pin,1)
valu= io(pi,pin) [print]
print valu
wait

[off]
io(po,pin,0)
valu= io(pi,pin) [print]
print valu
wait

[print]
print valu
wait

[Exit]
wprint |<a href="./edit"> Edit</a>|
end

Re: valu= io(pi,pin)

PostPosted: Sun Feb 25, 2018 11:07 am
by Luc Volders
You made several mistakes, which are due (I believe) by not fully understanding the syntax of ESP-Basic.

First:
You should put a wait statement after the main part of the program, before the button routines start.

Second:
Reading the IO pins is done with laststat

So here is your complete edited program:

Code: Select allpin = d6
io(po,pin,0)
cls
button "On",[on]
button "Off",[off]
button "Exit",[Exit]
wait


[on]
io(po,pin,1)
print io(laststat,pin)
wait


[off]
io(po,pin,0)
print io(laststat,pin)
wait

[Exit]
wprint |<a href="./edit"> Edit</a>|
end


Hope this helps.

Luc

Re: valu= io(pi,pin)

PostPosted: Tue Feb 27, 2018 3:45 pm
by msvb100
Bedankt voor de hulp....

(Thank you for the assistance....)