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)
Thanks
That should do it I think, however it is untested (and I really need to revisit this code to change a few things I dislike about how I wrote it - which don't change how it works, it's just me being picky)
Edit: Or use Robot-Docs script (that'll teach me to post and eat dinner at the same time, I missed the updates...)
LoL thanks. I will try it out and see. The more I'm looking at it. The more sense the code makes. LoL know what I mean.
Yep, I know exactly what you mean. That is what I try to achieve with my scripts too, hence the comments throughout most of them.
Give it a go, see what happens, I'm usually around to guide you if you get stuck.
:D hey Rich it works great. man, thanks, and i know i will be asking a few more questions later
Is the green face supposed to be
or D
Is the yellow face supposed to be
or )
green is : D yellow is " )
no spaces, but it might not matter...