Rafiki Front Bumber icon Rafiki Front Bumber — Rafiki front bumper plugin: reads 4 proximity sensors via serial, updates ARC variables, blocks motor movement toward detected obstacles for SLAM Try it →
Asked — Edited
Resolved Resolved by Rich!
2 Participants

If-Then Programming

Can anyone give me info on how to program an If-Then sequence? Ex. If the robot sees a red ball, it will stop, if it sees a green one, it will go forward. Also a screenshot of the programming would be helpful. Thanks!


ARC Pro

Upgrade to ARC Pro

Experience the transformation – subscribe to Synthiam ARC Pro and watch your robot evolve into a marvel of innovation and intelligence.

Author Avatar
United Kingdom
LinkedIn Twitter Google+ YouTube
#1  

I have covered IF statements in a few topics, I'll list them in a sec. But to answer this question is very simple;

First you need to make sure you have the camera control set up for colour detection, this will give ARC the global variable called $CameraObjectColor

Then your script would need the following IF statement


IF($CameraObjectColor = "Red")
  Stop()
ELSEIF($CameraObjectColor = "Green")
  Forward()
ELSE
  # Neither colour detected
  Print("No colour detected, awaiting colour to proceed")
EndIf
#3  

Thanks! I will test that out.

Author Avatar
PRO
Synthiam
LinkedIn Thingiverse Twitter YouTube GitHub
#4  

There are dozens of example projects in ARC that demonstrates everything.

  1. Start ARC

  2. Press OPEN file the FILE menu

  3. Press the EXAMPLES button

You will now see sub directories for SCRIPT examples and FUNCTION examples

Author Avatar
United Kingdom
LinkedIn Twitter Google+ YouTube
#5  

I still keep forgetting about the examples already in ARC, must remember next time:)

#6  

Thanks for the help! I am excited to test it out!