Why doesn't my circuit work?
Hello. I copied a circuit from online and pasted it. I used the same code, but it doesn't work for me. Why? I only used one motor, so I didn't connect ENA, IN1, and IN2 at all.
int motor1pin1 = 2;
int motor1pin2 = 3;
void setup() {
// put your setup code here, to run once:
pinMode(motor1pin1, OUTPUT);
pinMode(motor1pin2, OUTPUT);
pinMode(9, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//Controlling speed (0 = off and 255 = max speed):
analogWrite(9, 100); //ENA pin
//Controlling spin direction of motors:
digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, LOW);
delay(1000);
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, HIGH);
delay(1000);
}
Code :
int motor1pin1 = 2;
int motor1pin2 = 3;
void setup() {
// put your setup code here, to run once:
pinMode(motor1pin1, OUTPUT);
pinMode(motor1pin2, OUTPUT);
pinMode(9, OUTPUT);
}
void loop()
// put your main code here, to run repeatedly:
//Controlling speed (0 = off and 255 = max speed):
analogWrite(9, 100); //ENA pin
//Controlling spin direction of motors:
digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, LOW);
delay(1000)
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, HIGH);
delay(1000)
}
Battery all?