drephreak
Hello. Just a quick update and some issues I have. The hex that is still nameless is awesome. ARC 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 ARC 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.
Also, there was a GOTO at the beginning which just went to the next line...
The GOTO when finding the action is kind of irrelevant because the code can be placed wthin the IF/ENDIF
PS, when pasting code, place it within the [ code ] and [/ code ] blocks so it will be easier for others to read
Shouldn't that also be a <=? If I am reading this right, it is biting when the target is not near it, instead of when it is in range.
Alan
Ah yeah - I don't know which way the sensor returns. Does that sharp sensor return a higher voltage when near and lower voltage when away? I forget - I believe it's the latter. I feel the sensors output voltage is relative to the amount of IR received from the IR Receiver, which would mean higher voltage is closer object. In which case, he would have it correct with a >=
*EDIT: Yes, he has it correct according to the sharp datasheet graph
Ok, cool.