
drephreak
Hello.
Just a quick update and some issues I have.
The hex that is still nameless is awesome. EZ Builder is super awesome.
Ive got the hex walking ( not quite in a straight line) and rotating left.
Ive also managed to set up a sharp IR sensor to initiate attacks.
EZ builder crashes if I use the radar but I found an IR script and adapted it for my use which kind of works.
Now you guys need to understand I have written a few basic websites in html back in the 90s and dabbled a little with arduino and have recently started looking at C++ so I am relatively new to this.
The script is supposed to initiate an attack and bite from the IR reading.
if messed with it for about a day now and it has worked on a couple of occasions but I think there are some conflicting instructions that im yet to understand with my limited knowledge of EZ Builder hierarchy and scripting.
I have added some pics to show the Standing position, the attack position and the fangs which I have yet to attach to a mini servo I have wired to the EZ-B.
So on to the Script
I have had it running and detecting the IR distance and going into attack and making sounds, it even did it once when I didnt expect it and it made me jump.
but sometimes and now every time it just disconnects the EZ-B when the IR is detected and the script keeps running.
Im kinda stabbing in the dark changing stuff around and its not working now.
here is the script:
# Bite using IR sensor on ADC port
# Adjust values below for configuration
$iradcport = ADC0 # Change for ADC Port with sensor attached
$maxirdistance = 100 # Change for maximum distance from object before biting in units
Goto(detect)
:detect
$currirdistance = GetADC($iradcport)
if ($currirdistance >= $maxirdistance)
Goto(bite)
endif
Sleep (50)
Goto (detect)
:bite
ControlCommand ( "Auto Position", AutoPositionAction, "Attack")
Servo (D11,100)
ControlCommand( "Soundboard V4", Track_4 )
Sleep (100)
Servo (D11,50)
Return()
Ok Script dogs, tear it apart !
Andre
Check and wait until the Auto Position action is completed.
2) Also, there was a GOTO at the beginning which just went to the next line...
3) The GOTO when finding the action is kind of irrelevant because the code can be placed wthin the IF/ENDIF
4) PS, when pasting code, place it within the [ code ] and [/ code ] blocks so it will be easier for others to read
Code:
Alan
*EDIT: Yes, he has it correct according to the sharp datasheet graph