Hi im trying to control a small car using two motors and two small H-bridges (sn754410ne) but i am having problems programming it. currently what i am trying to do is just get it to drive round a "circuit" which is what im trying to program into it.
//H-bridge 1 (steering)
const int motor1Pin = 3; // H-bridge leg 1 (pin 2, 1A)
const int motor2Pin = 4; // H-bridge leg 2 (pin 7, 2A)
const int enablePin = 9; // H-bridge enable pin
const int ledPin = 13;
//H-bridge 2 (drive wheels)
const int motor3Pin = 5; // H-bridge leg 1 (pin 2, 1A)
const int motor4Pin = 7; // H-bridge leg 2 (pin 7, 2A)
const int enablePin1 = 10; // H-bridge enable pin
void setup() {
// set all the other pins you're using as outputs:
pinMode(motor1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
pinMode(enablePin, OUTPUT);
pinMode(ledPin, OUTPUT);
// set enablePin high so that motor can turn on:
digitalWrite(enablePin, HIGH);
//--------------------------------------------------------------------
// set all the other pins you're using as outputs:
pinMode(motor3Pin, OUTPUT);
pinMode(motor4Pin, OUTPUT);
pinMode(enablePin1, OUTPUT);
// set enablePin high so that motor can turn on:
digitalWrite(enablePin1, HIGH);
}
void loop() {
//should turn front wheels left and right
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin, LOW);
}else{
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
}
//should drive and reverse
{digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
}else{
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
}
void loop is where my problem lies it tells me that motorPin1 has not been declared and if i remove digitalWrite(motorPin1, HIGH); it tells me the same for the next part.
can anyone help me solve this problem, i am new to arduino but i have done most of the example codes including motors.
thankyou in advance.
beechey