This is the improved version of the Edwardo V2.0 posted by Grimjack1973. We are working in colaboration and had to change the chasis design due to a few flaws. We have finished assembly and moved onto programming however I have hit a problem in the programming area. The aim is to allow the robot to completely non-autonomous roam around while using the pan-tilt servo system to move the Sharp IR sensor located at the front to perform obstacle avoidance. I have provided a text file of the sketch along with as much information as possible in the "additional information" section and shall be happy to provide anymore if needed.
Actuators / output devices: Two Tamiya dual gearbox
Control method: completely non-autonomous
Power source: Two 8.4V 2200mAh NiMH Rechargable 3+4 AA Battery Packs
Programming language: Arduino ide
Sensors / input devices: Sharp GP2Y0A21YK0F IR sensor
It looks pretty good actually. A few things though:
First off, I would put the “direction” routines below the main loop and instead start the sketch with the setup loop. Its just sorta the “standard” way of things.
The main issue you have is the fact that while the servos are scanning back and forth (in the for loop), they are only doing that. You are not checking your sensor during these sweeps. Currently, you sweep from L to R, then from R to L then take one single reading, then you go into your IF’s and then turn/forward etc. Instead, you shoud do a sensor check inside of the for loop that is moving your servo.
Also, you are using an analog sensor and an analog pin, but you are treating it as if it is digital. Your “are we too close?” statement is doing a digital read of that sensor. This is incorrect. I would do some stand-alone testing of your sensor using an analogRead and the serial monitor and you can get an idea of the numbers coming out of the sensor and how to work with them.
Thank you I am currently reworking the sketch base off your feed back; However, I had another question. in the code where it states
"void advance(char a,char b)"
is there any way to adjust that for 4 charaters such as:
"void advance(char a,char b,char c,char d)"
I ask because that always errors out for me as does using 2 characters trying to script for 4 motors. Are two characters all thats needed to run 4 motors. as I listed in the additional infomation section we have two dual-motor cases each running 2 DC motors.