I cant seem to be able to attach as i think the circuit file is large but i have done that and even connected 5v motor driver to arduino vin
The 3 left pins on the driver header are needed for the A motor to work.
EDIT
The Arduino pin 10 wire is not needed.
You need Motor 1 enable, IN1 AND IN2 connected to appropriate Arduino pins.
That battery is too feeble for the job and won't last long at all. A set of AAs connected to give you an appropriate voltage for your motor (plus driver loss) will do better.
What should i put on in2
Where can I get those? please send me a link ( not on amazon as i cant order from there) if you can find one on flipkart as it delivers to My Country
While i was replying i noticed that the motor had stooped rotation from 1 rotation per 10 min to 1 rotation per 3 min. What could be reason behind this
You need Motor 1 enable, IN1 AND IN2 connected to appropriate Arduino pins.
how to do it please tell
uh... i cant buy from amazon...pls search something on https://www.flipkart.com/ as i bought my arduino and motor driver there
Thanks Ill check it out. Please tell me what to do of IN2
Make sure you get a battery holder that holds 8 AA batteries.
Letβs see your current sketch.
Please see post no 28
should i buy this?
For experimenting just use the battery holder and 8 AA alkaline batteries.
ok. i am sending code,only difference in wiring is that i have connected IN2 to the corresponding pin in the code
int Xpin = A0;
int Ypin = A1;
int Xval;
int Yval;
int m1Pin1 = 2;
int m1Pin2 = 3;
int m2Pin1 = 4;
int m2Pin2 = 5;
int m1SpeedPin = 9;
int m2SpeedPin = 10;
int m1Speed;
int m2Speed;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(Xpin, INPUT);
pinMode(Ypin, INPUT);
pinMode(m1Pin1, OUTPUT);
pinMode(m2Pin1, OUTPUT);
pinMode(m1SpeedPin, OUTPUT);
pinMode(m2SpeedPin, OUTPUT);
digitalWrite(m1Pin1, HIGH);
digitalWrite(m2Pin2, LOW);
digitalWrite(m2Pin1, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
Xval = analogRead(Xpin);
Yval = analogRead(Ypin);
m1Speed = map(Xval, 0, 1023, 0, 255);
m2Speed = map(Xval, 0, 1023, 0, 255);
analogWrite(m1SpeedPin, m1Speed);
analogWrite(m2SpeedPin, m2Speed);
if (Yval < 470 )
{
m1Speed = 0;
} else if (Yval > 550) {
m2Speed = 0;
} else {
m1Speed = map(Xval, 0, 1023, 0, 255);
m2Speed = map(Xval, 0, 1023, 0, 255);
analogWrite(m1SpeedPin, m1Speed);
analogWrite(m2SpeedPin, m2Speed);
}
delay(100);
Serial.print(" m1spped = ");
Serial.print(m1Speed);
Serial.print(" m2speeed = ");
Serial.println(m2Speed);
delay(1000);
}