I am new to programming and I started this 2 WD avoidance bot project and I look up a few code online and every code seems to have error, the right wheel is not rotating the same direction of the left wheel, if there is any code I can look up to or I can base on would be great, any tip or suggestion would greatly be appreciated.
Thank you!
The code that I messed around with is shown below.
Please read the post at the start of any forum , entitled "How to use this Forum".
This will help with advice on how to present your code and problems.
We need to see your code and tell us what it doesn't do.
Also we need a schematic, a hand drawn diagram is fine, just label components and pin names along with including the power supply.
Post the code that you are having trouble with and we can, probably, help you to get it to work. Read the forum guidelines to see how to properly post code and some information on how to get the most from this forum. Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
Post a schematic of the project wiring. Include all components, their part numbers and/or values and power supplies. Post data sheets for the motors, motor drivers and sensors. Hand drawn, photographed and posted is preferred over fritz diagrams.
Photos of the project that show the wiring and component layout can also be valuable.
The more information that you provide, the more and faster help you can get.
I edited the post for the code, for what it doesn't do the bot currently feels like it is just doing just a pattern of sequence but it does dodge some obstacle. Here is a diagram basically I connected the Vcc and Gnd to the Vcc and Gnd of the L9110s since I am using a powerbank to power everything up .
I edited the post for the code, Here is the diagram basically I connected the Vcc ang Gnd to the Vcc ang Gnd of the L9110s since I am using a power bank to power everything up
Hi,
You need to write some basic test code for the motor and for the ultrasonic.
A code JUST for the motor controller, get the wheels moving fwd then bwd.
A code JUST to communicate with the ultrasonic, to make sure it works.
For the moment forget about your other code, lets prove that the hardware works.
I don't think the idea is good.
If your only problem is that the wheels are turning in different directions, you can try to exchange the connection of the two wires of one motor or make the appropriate change in the program. It depends on what you prefer.
If you are commanding both to got FWD, I assume one motor has been turned around to be on the other side.
So both FWD will mean one goes forward, the other back.
In your motor test code do you command them both to go FWD at the same time?
If so, do they BOTH go in the robots FWD direction?
If it does, just swap the wires to the motor going in the wrong direction.
now it goes in both direction but after one whole spin the other wheel goes into the opposite direction and after doing one whole it goes back to the correction rotation and its doing it over and over so basically it is not going forward it is just doing circles, seems like the ultrasonic sensor is not doing its job should I put a serial print?
1.I just want it to go forward until it detects something.
2.Probably around 10cm.
3.Go backward and turn right or left then goes forward again.
4.Continues to go forward.