
leonardo46
Italy
Asked
— Edited

I'm a basic and assembler programmer ( PIC MCUs). I'm trying to put ezb scripts at work. I have a pot connected to adc0 (i.e. 0-3.3 V) and move the pot. I write this easy script in movement script, triggered by "forward" action panel :
sayezbwait("man") :auto $av=getadc(adc0) if $av>20 sayezbwait("dog") else sayezbwait("cat") endif goto(auto)
"man" is spoken once. Nothing else happens. I should have missed some banal detail Please help.
example #2:
Hello PTP,
I was looking at this post as I am interested in doing similar things. Just want to clarify what is going on in the following statement line:
if($prevMoving!=$moving AND $moving)
Are we saying here that if the previousMoving state is not equal to moving (false) AND the variable $moving is now equal to true then we are moving?
Also when doing comparisons like if($direction="Stop") shouldn't this statement read: if($direction=="Stop")?
Just curious about these two issues and thanks as always for your clarification and help !Rick

PTP, I see I have a lot to learn... despite some decades in programming PICs.
Please, to help, write a few lines, doing simply this:
read adc0, sayezb "up" if >128, or "down" if <128, and do this for ever.
I'd expect a up/down message from ezb whenever the voltage crosses the treshold.
This way I could hopefully understand how to work with EZB.
I'm going on testing some code , regarding getadc(adc0). I used the control called "read adc", to check the wiring , and I was surprised seeing that there I read , for adc0 , always 1,05 V, (value=82) whatever voltage I input to adc0 (0-to 3.3 V), even with the pin non connected . I have a meter connected to the pin. Same thing happens for other adc pins.
This explains some unexpected behavior of my code.
Can somebody explain why "read adc" doesn't work ? What's going on ?
Hi,ptp. Never mind about my previous posts. I solved my banal problem myself : some missing parenthesis, and wrong pin for adc. (a0 exchanged with a7 , I thought a0 on the same side as d0, I didn't look at the datasheet). Sorry, I'm a newcomer in EZB.
@Rick,
EZ-Script is neither a BASIC or C compliant language, so there are some curiosities:
Equal Operator ( = ) like Basic, C uses ( == )
Not Equal operator ( != ) like C, Basic uses ( <> )
Label is ( :my_label ) , C / BASIC is ( my_label: )
ElseIf, BASIC does not have, C is (else if)
if ( condition ), BASIC does not need braces, C requires braces
making short = is the equal operator
to avoid mistakes you need to rely on the ARC EZ-Script helps or look for examples in the forums.
Thanks PTP,
Was I correct in my thoughts on the moving statement in my post above? Thanks again ! Rick
Hi, DJ Sures. I wrote some simple code. But often I had unpredictable results, i.e. statements not executed, or executed more than once, or with unpredictable timing, etc. I never worked in a multi tasking environment, and don't understand how to manage many statements working together (as you say, " threaded"). Nothing about this in any tutorials. Can you help? Where to learn such things? Otherwise I'll have to go back to my beloved PICs, where everything is reliable, exactly timed, extremely fast, and no Os to interfere with my code.