Hi guys, sorry if I do something wrong but I am a beginner. I has a basic chasis with 2 motors, a SR04 and a Nano board. I am trying to spin only one wheel if the distance to an object is less than 10 cm. I can read the distance in the Serial Monitor by its self but when I connect the motors the distance goes to 0 and the wheels keep spinning forever. I am not sure what is wrong with my code.
I attached my code and a picture similar to my setup.
In my code this should be seen:
D3 pin is trigger for SR04
D2 pin is echo for SR04
D7 and D8 pin goes to the middle pin of the 2222A transistor, so it's an output.
Thanks.
robot.ino (1.11 KB)