Motor Connections
Connection and Code to create a basic car with differetial drive (2 wheels + castor). Any amount of sensors may be added to this for various applications.
Components :
- Arduino Uno
- Bread Board
- Chassis
- Wheels x 2
- Voltage Regualtor LM 7805
- Jumper Wires
- Motors x 2
- Castor wheel
- 12V Battery (Power Source)
- L293D (Motor driver)
Connections :
Code :
To check the working of the motors :
int lmotor_input1=10;
int lmotor_input2=11;
int rmotor_input3=5;
int rmotor_input4=6;
void setup()
{
Serial.begin(9600);
pinMode(motor_input1,OUTPUT);
pinMode(motor_input2,OUTPUT);
pinMode(motor_input3,OUTPUT);
pinMode(motor_input4,OUTPUT);
}
void loop()
{
Serial.println("Straight");
analogWrite(motor_input1,255);
analogWrite(motor_input2,0);
analogWrite(motor_input3,255);
analogWrite(motor_input4,0);
delay(1000);
Serial.println("LEFT");
analogWrite(motor_input1,0);
analogWrite(motor_input2,200);
analogWrite(motor_input3,200);
analogWrite(motor_input4,0);
delay(800);
Serial.println("RIGHT");
analogWrite(motor_input1,200);
analogWrite(motor_input2,0);
analogWrite(motor_input3,0);
analogWrite(motor_input4,200);
delay(800);
Serial.println("BACK");
analogWrite(motor_input1,0);
analogWrite(motor_input2,255);
analogWrite(motor_input3,0);
analogWrite(motor_input4,255);
delay(800);
}
Comments
Post a Comment