Cool looking bot, and an Arduino Mega should give you lots of room to experiment.
One suggestion: Your code is all full of formatting gobbledygook. Instead of cut and pasting it into the post, you can attache it as a file. Much cleaner.
Any chance you can post some video of it in operation?
Thanks for posting the video. Looks like pretty solid navigation. I was surprised by the orientation of your SRF05s. What made you decide to have them pointed across each other’s path? I assume based on your results that there is no interference between them.
This looks great! Are you using an arduino motor shield? I’m curious about your motor pins. You’ve got 2 pins per motor but you only define one per motor. Then I notice you’re using a digitalWrite to the defined pins and an analogWrite to the undefined pins. Clearly this is working but I don’t understand why. I’m new to C, though. Can you explain that to me?
The navigation is pretty decent it will coast around all day and not bump into a single object unless its below its eye level of course. Also I programmed in so that the distance at which the bot recognises an obstacle is also changeable.
I first though upon using 3 SRF05’s for the navigation, left, center and right. But then decided upon the cross eyes approach. In doing this I am able to scan both left, right and center using only two censors. please refer to the truth table below. The cone shape of the censors does pose a slight problem when they are so close together, but I have managed to calibrate them so that where they are now they are both just out of scan range of each other. I also leave 65ms between each send and receive echo sequence to allow the previous echos to die out, this eliminates any interference.
Yes, I am using a Motor Shield from DFRobot, the shield uses an external 3 x AA battery pack to power the motor’s and takes its power for the other components from VIN.
The reason there are 2 pins per motor is to facilitate PWM, the digitalWrite to M1/2 sets the pin to be high (+v) and the analogWrite to E1/2 specifies the speed that the motor should rotate.
Yep it works perfect, I would have stayed with that idea on my new bot but wanted to experiment with a servo to pan the SRF05, so far it is proving alot harder!