Asked
— Edited
Another script I've been writing is for the IR object avoidance as the built in control for IR doesn't work correctly with my IR sensor. I'm also trying to get to grips with EZ-Script so playing around is always a great idea in my book.
Adjust and/or comment on as you see fit. I've written it so it can be easily adjusted to suit your settings (and to show how variables can be used to make for easy adjustment over different projects/people)
# IR Detector Script
# Object avoidance using IR sensor on ADC port
# Adjust values below for configuration
$iradcport = ADC6 # Change for ADC Port with sensor attached
$maxirdistance = 35 # Change for maximum distance from object before avoiding in units
$irreverseturn = 0 # Reverse before turn? 0 = no, 1 = yes
$irturndirection = 0 # Change 0 = left or 1 = right
$irturnamount = 500 # Change for how long to turn for in ms
$irreverseamount = 500 # Change for how long to reverse for in ms (if applicable)
$irmovementspeed = 255 # Change for movement speed
# -- Do not modify below this line --
Goto(detect)
:avoid
IF ($irreverseturn = 1)
reverse($irmovementspeed,$irreverseamount)
ELSEIF ($irturndirection = 0)
Left($irmovementspeed,$irturnamount)
ELSE
Right($irmovementspeed,$irturnamount)
ENDIF
Return()
:detect
$currirdistance = GetADC($iradcport)
IF ($currirdistance >= $maxirdistance)
Goto(avoid)
ENDIF
Sleep (50)
Goto(detect)
OK. Thanks. I will give it a go. .. I might try and get the ping to swing LoL with a micro servo.
I have one ping that pans and more will be stationary. All of my IRs do not pan.
@Rich, you are the man!