Hello guys
I made the connections as per my knowledge. However, the motors dont work. Could you help me out??
Sorry for the confusing connections. And, i have powered my arduino through the usb cable.
Thankyou guys, you know this one!!!
Hello guys
I made the connections as per my knowledge. However, the motors dont work. Could you help me out??
Sorry for the confusing connections. And, i have powered my arduino through the usb cable.
Thankyou guys, you know this one!!!
oh…and here is the
oh…and here is the program
int motor_left[] = {7, 6};
int motor_right[] = {5, 4};
// --------------------------------------------------------------------------- Setup
void setup() {
Serial.begin(9600);
// Setup motors
int i;
for(i = 0; i < 2; i++){
pinMode(motor_left[i], OUTPUT);
pinMode(motor_right[i], OUTPUT);
}
}
// --------------------------------------------------------------------------- Loop
void loop() {
drive_forward();
delay(1000);
motor_stop();
Serial.println(“1”);
drive_backward();
delay(1000);
motor_stop();
Serial.println(“2”);
turn_left();
delay(1000);
motor_stop();
Serial.println(“3”);
turn_right();
delay(1000);
motor_stop();
Serial.println(“4”);
motor_stop();
delay(1000);
motor_stop();
Serial.println(“5”);
}
// --------------------------------------------------------------------------- Drive
void motor_stop(){
digitalWrite(motor_left[0], LOW);
digitalWrite(motor_left[1], LOW);
digitalWrite(motor_right[0], LOW);
digitalWrite(motor_right[1], LOW);
delay(25);
}
void drive_forward(){
digitalWrite(motor_left[0], HIGH);
digitalWrite(motor_left[1], LOW);
digitalWrite(motor_right[0], HIGH);
digitalWrite(motor_right[1], LOW);
}
void drive_backward(){
digitalWrite(motor_left[0], LOW);
digitalWrite(motor_left[1], HIGH);
digitalWrite(motor_right[0], LOW);
digitalWrite(motor_right[1], HIGH);
}
void turn_left(){
digitalWrite(motor_left[0], LOW);
digitalWrite(motor_left[1], HIGH);
digitalWrite(motor_right[0], HIGH);
digitalWrite(motor_right[1], LOW);
}
void turn_right(){
digitalWrite(motor_left[0], HIGH);
digitalWrite(motor_left[1], LOW);
digitalWrite(motor_right[0], LOW);
digitalWrite(motor_right[1], HIGH);
}
Just to cover the obvious.
Just to cover the obvious. Have you connected the motor battery with Arduino ground?
i havent geir…i didn’t
i havent geir…i didn’t know that…lemme try that
Enables
Connect your enable pins to something. For initial testing, just connect them to +5v. Once it works with this set-up, then you can transfer these enable pins to (2) PWM pins on your arduino. These PWM pins will become your speed conrol while the direction pins (the ones you are using now) will continue to work in the same way.