I am building a robot vehicle that avoids objects. Two DC motors, attached to M1 & M2, drive tank like treads for mobility. An ultrasonic sensor mounted on a seervo “looks” around for obsticals to avoid. The ultrasonic sensor takes power from the 5v pin on the motor shield while trig and echo are attached to A4 and A5 respectivly. The Servo is attached to Servo 2.
I downloaded a sketch off the Internet that has nearly all the functions I need to at least get the robot up and running in a basic way. I had to make two very small changes to the code to get it to compile, but other than that the sketch is just as I obtained it with no alterations to how it functions.
The issue is that the only thing that is functioning on the vehicle is the servo. The two motors do not run, and print statements I inserted into the code for debugging showes that readPing() calls to the ultrasonic unit always returns zero even if an object is 10 or so inches in front of it.
I am wondering if the problem might be a bad motor shield, however it does run the servo correctly. I suppose, however, that its possible for some aspects of the shield work correctly, while others do not.
Some guidence on how to procede with troubleshooting would be greatly appreciated.
The code is too long to post here with out exceeding the max characters in a post, however the code is listed in an article about how to build a robot similar to mine. Scroll about half way down the page to find where the code begins. Click here to see the article