I have a rc car that had an rx2 chip which i replaced with an arduino bored so that i could send logic signals to control the car. I then added a motor control circuit to the power for the rear motors that is designed to give a slow start using a capacitor and also give the option of setting the speed. since using this circuit board i've found that the program doesnt run consitently. the steering for the vehicle is controlled by a servo which seems to run according to the programming. sometimes the motors start straight away and sometimes start 3secs too late or finish really early. or even not start at all. i dont have a deep understanding of electronics but could a capacitor be holding charge and not letting the current through. i dont think its the programming but again i dont have a deep understanding just the programming seems to simple to cause such issues, any advice would be appreciated. the code used is shown below.:
/*
Car Test
*/
#include <Servo.h>
Servo myservo;// create servo object to control a servo
int forward = 12; // forward pin
int reverse = 11; // reverse pin
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
// initialize the digital pins as an outputs:
pinMode(forward, OUTPUT);
pinMode(reverse, OUTPUT);
}
void go_forward()
{
digitalWrite(forward,HIGH); // turn forward motor on
digitalWrite(reverse,LOW); // turn revers motor off
}
void stop_car()
{
digitalWrite(reverse,LOW); // turn revers motor off
digitalWrite(forward,LOW); // turn forward motor off
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
delay(2000);
go_forward();
delay(2000);
myservo.write(115);
delay(2000);
myservo.write(65);
delay(500);
myservo.write(90);
delay(2000);
stop_car();
delay(5000);
}