The robot car moves forwards and backwards perfectly and the sensor and servo which pans it also seems to work fine but as it comes closer to obstructions it does not seem to process the actions programmed to reverse or avoid collision. I am more of a script kiddie, Cut and pasted codes from various sources on the web. None which was using the combination I have used so had to figure it out on my own and now stuck….F1 F1 F1 anyone
Hi Kumar, Thanks for joining the Lab! Can you share your code? Please post your code on http://pastebin.com/.Then copy and past the link that generates. So it’s easier to help
Hi Rui, I have pasted the code i have used. The previous code where the rover servo was panning, has stopped for some reason. rechecking the code, still i am stuck on this. Now it seems to keep moving forwards and backwards only. I should have saved the previous code which i had it working, I kept modifying the same and lost the original one which atleast was moving forwards and the servo pans and can see the distance measurements on the serial monitor. Alas foolish of me to have modified the same code without doing a save as before modifying it. Please tell me where i need to correct the code. I would like to this time understand where i am wrong. Thanks in Advance. regards Kumar http://pastebin.com/4yJENnhM
You need to be careful with the motor connections . When you can any of the motor funtctions where direction can be BACKWARD, FORWARD or RELEASE. The Arduino doesn’t actually know if the motor is BACKWARD orFORWARD , so if it’s rotating in the wrong direction, simply swap the two wires from the motor to the shield and it should work.
I don’t have the shield, so I can’t personally test the project. But before you add the ultrasonic sensor functionality make sure you can control the motors in the right direction. You should start with a more basic example https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/overview and make the backward and forward movements