Asked — Edited

Help With Script Again

Very simple logic, just don't know the commands in ARC... Just added a maxbotics analog distance sensor. It works in ARC. What I would like is when the distance is equal to or less than 50 speak out the ezb. I set up an analog port and I'm trying to use the adc wait command, from there? Thanks Chris


ARC Pro

Upgrade to ARC Pro

Your robot can be more than a simple automated machine with the power of ARC Pro!

#9  

Is there a way to make it loop? To make it work I have to sit and push start script. I would like to have it sense an object and say it automatically, not just once. If I walk in front of the robot I want to say it, then when I get out of its path , and return to its path say it again. I will build upon this with eventually stopping the robot.

#11  

it works only when I push the start script button for me. The script runs only once.

#12  

Check my syntax as I am doing this from memory.. you need to check what values the sensor is feeding back before you can use it in a script...


$x=0
$quit=1

RepeatUntil($quit=0)

$x=getadc(adc7)

print($x)  #see what values the sensor is giving


sleep(50)

endrepeatuntil


#13  

I changed the code above to repeat forever so you can use it to see what values the sensor is continuing to put out...

Once you figure out what the sensor is reading and value you need you can then modify the code to actually use in your project...

#14  

Hey Richard the above code does run forever like you said. But when I add an If statement ($x) < 50) I get an error, Something about nesting. Ive had enough for tonight. Thanks for your help

#15  

Hey Kamaroman68 sorry to disturb but the reason why your getting an error message about nesting is because ($x)<50) is because you only have one pair of parentheses and a leftover one. When they say "nesting" they're saying your parentheses do not match up. I 'll give an example: (5+(3+2) if this was in a code I would get a nesting error because my parenthesis don't match up. I suggest reviewing Richard's previous example.

                                                           Happy building,
                                                                    Asher
#16  

This code should work... again, check my syntax before running....



$x=0
$quit=1

RepeatUntil($quit=0)

$x=getadc(adc7)

if($x&lt;50)  #This part will only run if $x is less than 50

SayWait(&quot;Object near&quot;)

endif

print($x)  #see what values the sensor is giving

sleep(50)

EndRepeatUntil


This simpler version should work too...


:top

ADC_Wait(ADC7,LOWER,50,50) 

SayWait(&quot;Object near&quot;)

goto(top)