Beginners: please read this post and this post before posting to the forum.
0 Members and 1 Guest are viewing this topic.
int motor1Pin1 = 3; // pin 2 on L293Dint motor1Pin2 = 4; // pin 7 on L293Dint enablePin1 = 9; // pin 1 on L293Dint motor2Pin1 = 5; // pin 10 on L293Dint motor2Pin2 = 6; // pin 15 on L293Dint enablePin2 = 10; // pin 9 on L293Dvoid setup() { pinMode(motor1Pin1, OUTPUT); pinMode(motor1Pin2, OUTPUT); pinMode(motor2Pin1, OUTPUT); pinMode(motor2Pin2, OUTPUT); pinMode(enablePin1, OUTPUT); pinMode(enablePin2, OUTPUT); // set enablePin high so that motors can turn on: digitalWrite(enablePin1, HIGH); digitalWrite(enablePin2, HIGH); digitalWrite(motor1Pin1, LOW); digitalWrite(motor1Pin2, LOW); digitalWrite(motor2Pin1, LOW); digitalWrite(motor2Pin2, LOW); Serial.begin(9600);}void loop() { while(Serial.available() == 0); int val = Serial.read()-'0'; // if input is '1', motor will turn on one direction: if(val == 1) { digitalWrite(motor1Pin1, LOW); digitalWrite(motor1Pin2, HIGH); digitalWrite(motor2Pin1, LOW); digitalWrite(motor2Pin2, HIGH); } // if input is other, motor will turn on opposite direction: else { digitalWrite(motor1Pin1, HIGH); digitalWrite(motor1Pin2, LOW); digitalWrite(motor2Pin1, HIGH); digitalWrite(motor2Pin2, LOW); } delay(200);}
If they are, then manually test the inputs of the motor controller with a wire connected to V+ or GND with a resistor in line.