Hello members!
I am trying to build a robot car for my highschool project and I'm stuck on this problem. I was able to "hack" into the electronics of the car and connect the wires that move it left and right onto the arduino, and I was also able to make it go left and right. However, the only problem was that it turned left too fast, or turned right too fast. So I thought of adding a duty cycle to it of 20% to "reduce" the voltage and make it turn slower. I just need some help because when I add in the code for the duty cycle, I can't make the motor stop moving. Here is my code, just need it to move for 1 second and then stop moving. I tried so many things, I don't know how I can make it stop moving.
int left=12; //apply 1 to turn left
int right=11; //apply 1 to turn right
//This is the part of the code that works on reducing the speed of the motor
digitalWrite(left, LOW);
digitalWrite(right, HIGH);
delayMicroseconds(200); // Approximately 20% duty cycle @ 1KHz
digitalWrite(right, LOW);
delayMicroseconds(1000 - 200);