I have bought a controller and two motors and connected them up to my Arduino. However I cannnot make the motors move. Can someone help. The code is below:
case 'f':
Serial.write("forwards");
//To move the motor forward: IN1=H, IN2=L, ENA=H
digitalWrite(iEnableMotorA, HIGH);
digitalWrite(iInOneMotorA, HIGH);
digitalWrite(iInTwoMotorA, LOW);
analogWrite(iEnableMotorA, 75); //PWM Speed Control
delay(1000); // waits for a second
digitalWrite(iEnableMotorA, LOW);
digitalWrite(iInOneMotorA, LOW);
break;
It is being powered by 5v from the Arduino and the ground runs back to the Arduino.
The pins are connected as such
int iEnableMotorA = 3; //Enable Motor A
int iInOneMotorA = 11; //IN1 for motor A
int iInTwoMotorA = 6; //IN2 for motor A
int iEnableMotorB = 5; //Enable Motor B
int iInThreeMotorB = 10; //IN1 for motor B
int iInFourMotorB = 9; //IN2 for motor B
I got it to move once but for it to move more I would need to re-flash the Arduino. With the current code it just makes a beeping noise. Any idea what that means? Yes I see that printed message OK.
With the current code it just makes a beeping noise. Any idea what that means?
Well that code is only turning the motor on for a second so it might beep.
What current does the motor take, powering a motor off the USB is not the best idea because the interference from the motor often causes the arduino to reset.
I got it to move once but for it to move more I would need to re-flash the Arduino.
That is an odd thing to say, it is not how an arduino normally works.
It beeps also for 10 seconds, the sound comes from the controller.
According to the spec:
The logical part of the operating current range: 0 ~ 36mA
By re-flash, I mean I need to put the sketch back onto the Arduino. I think the HW part is right as I have got it to move, I just don't remember exactly what I did. Is it right that I am setting the enable pin with the PWM value? So, i only need to set the IN1 and IN2 to high or low?
Quote
The logical part of the operating current range: 0 ~ 36mA
No how much current does your motor take? That is the important value in determing if you can run it from the USB or if you need and external supply.
By re-flash, I mean I need to put the sketch back onto the Arduino.
No nothing should take the sketch out of the arduino once you have put it in. It keeps the same sketch until you put in another one.
I think the HW part is right as I have got it to move
Well it moved once, but maybe you fried it by doing something wrong.
I repeat how have you got this wired up, it sounds like you are not supplying any motor power.
Those yellow pins have been described except the 5v, which goes to the Arduino + the GND which also goes to the Arduino, no other power source. Motor A/B of the blue pins are connected to the motors. The red wire is the one nearest the letter "M" in each case.
So with nothing connected to it you are driving your motors with zero volts therefore it is not a surprise if nothing moves. Connect it to the +5V from the arduino as well, if the motor is of sufficient low current it should move if you have not fried anything.