
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.
long job ?
you can copy the text/code "black window" and paste inside the ARC's script editor.
PTP, just wondering, what is your reasoning for having those three EndIf statements towards the end of your script. I would think that just one would do the trick.
Also, you have two If statements in a row. Is this possible?
if ($adc0_avg>50) if ($direction!="Forward")
Dave,
you can simplify:
but it looses readability, sometimes is easier to break multiple blocks, for example BASIC does not have elseif, so you need always to think if then else.
do you see other away to rewrite the ifs ?
Can be interesting exercise to see a different logic (I'm biased is my code)
Fast job ! I didn't know ezb was capable to support copy/paste !...
Code tested. It does no more than stop at once after the forward command. I eliminated the stop() command at the beginning. After that it goes forward, until the front sensor gets near an obstacle and then it stops, after several seconds (a long time!...). The voltage in READ ADC control panel, instead, changes immediately. Other sensors seem to have no influence in what's going on. No change in direction triggered by left/right sensors.
I saw in the code there is some average of adc reads. Could this help ? What had this code to do? Why side sensors not working? I have in ezb screen a voltage panel for each sensor, correctly measuring each distance in real time.
I forgot to say that ezb never says "near" or "far". It only says "stop", because I have sayezb ("STOP") in stop script.
Leonardo,
Can you upload/attach your project ?
More tests. I eliminated the 2nd stop() statement, (it stopped there !). now it reacts to the side sensors, turning right or left as required. But it keeps turning for ever, even when the loop is executed again with the front sensor without obstacles ("far" situation). It never says near or far. Only says what's in right,left,or stop scripts.
But the worrying issue is : response time is extremely long ! Note that the 3 READ ADC control panels for sensors change in realtime. EZBv4 , instead, reacts after some 2-3 seconds !... I DON'T UNDERSTAND WHY IT'S SO SLOW. This way is useless for controlling a robot !
Here it is roby.EZB