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

Unleash your robot's full potential with the cutting-edge features and intuitive programming offered by Synthiam ARC Pro.

United Kingdom
#17  

Simply use a repeatwhile(1 > 0) for a forever loop

So;


# Loop forever
RepeatWhile(1 > 0)

  # Wait until ADC value is lower than 50
  ADC_Wait(ADC0, lower, 50)
  
  # Speak through the EZ-B V4
  SayEZB("I have detected something in my path")

  # Wait until ADC value is higher than 50 to avoid constant repeats
  ACD_Wait(ADC0, higher, 50)

# Loop back
EndRepeatWhile

You can click the stop button or run a ControlCommand to stop a script so there's no need for an escape variable.

Or, if you wanted the value displayed;


# Loop forever
RepeatWhile(1 > 0)

  # Get the ADC Value
  $Distance = GetADC(ADC0)

  # Print the ADC Value
  Print("Distance: "+$Distance)

  # Or output to an LCD Display (Code may vary)
  I2CWrite(0,0x27,"TP","2","0")
  I2CWrite(0,0x27,"TT")
  I2CWrite(0,0x27,"Distance: "+$Distance)
  I2CWrite(0,0x27,0)

  # Check the value is lower than 50
  IF($Distance < 50)

    # If it is then speak warning
    SayEZB("I have detected something in my path")
  EndIf

  # Reduce processing load and comms
  Sleep(200)
EndRepeatWhile

In the above example you could replace the repeat with a simple :label and Goto()


:begin

  # Get the ADC Value
  $Distance = GetADC(ADC0)

  # Print the ADC Value
  Print("Distance: "+$Distance)

  # Or output to an LCD Display (Code may vary)
  I2CWrite(0,0x27,"TP","2","0")
  I2CWrite(0,0x27,"TT")
  I2CWrite(0,0x27,"Distance: "+$Distance)
  I2CWrite(0,0x27,0)

  # Check the value is lower than 50
  IF($Distance < 50)

    # If it is then speak warning
    SayEZB("I have detected something in my path")
  EndIf

  # Reduce processing load and comms
  Sleep(200)

# Loop back
Goto(begin)

#18  

OK so my saga continues..... at first all I wanted was to speak when an object was detected in its path. But after thinking about this, and already having the movement of the robot scripting in place (sort of) I would like to add to the complications. I looked at Rich's Ping roam script on the cloud but it didn't help much. What I have is one controller ezb4 in the robots head and one down at the drive base. The head board will need to interact with the base board as the head sensors are being used to determine distance to object. So..... I would like the robot to move on voice command, when approaching an object in path stop, say "I have detected an object in my path" Sleep(1000) then ask if it should proceed moving. An answer of yes will allow it to proceed while an answer of no well that's obvious... Any help is appreciated... Chris

United Kingdom
#19  

That's pretty simple. Do you want to be spoon fed or do you want the menu?

When using 2 boards you will need to tell the script commands which board to use (where applicable). This is denoted by the board number before the port i.e. Servo(0.D0, 60) or Servo(1.D0, 60)

The scripts provided so far should be a good base. but change the commands within the IF or after the ADC_Wait.

You want to use WaitForSpeech()

Quote:

WaitForSpeech( timeOut Seconds, phrases )

     Pauses and waits for one of the specified phrases to be spoken.

     Returns the phrase that was spoken.

     Will return timeout if no word is detected in the specified timeout length.

     Example: WaitForSpeech(30, Yes, No)

     Example: $value = WaitForSpeech(30, Yes, No)

and an IF to determine what to do. Check both out in the script manual.