Pinguino + 2 Amp Motor Driver Shield

Motor Shield Diagram:

Pin:

Pin Allocation:

Control Signal Truth Table:

For more information, please refer HERE

Example 1: Rotate dc motor in clockwise and counter-clockwise direction

Flow Chart:

Program Code:
int E1 = 5;
int M1 = 7;
int E2 = 6;
int M2 = 4;
void setup() 
{ 
pinMode(M1, OUTPUT);
pinMode(M2, OUTPUT); 
pinMode(E1, OUTPUT);
pinMode(E2, OUTPUT); 
} 
void loop() 
{ 
digitalWrite(M1,HIGH); //clockwise
digitalWrite(M2, HIGH);
digitalWrite(E1, HIGH); 
digitalWrite(E2, HIGH); 
delay(5000); 
digitalWrite(E1, LOW); //stop
digitalWrite(E2, LOW);
delay(2000);
digitalWrite(M1,LOW); //counter-clockwise
digitalWrite(M2, LOW);
digitalWrite(E1, HIGH); 
digitalWrite(E2, HIGH); 
delay(5000);
digitalWrite(E1, LOW); //stop
digitalWrite(E2, LOW);
delay(2000); 
}

Demonstration:
[youtube]http://www.youtube.com/watch?v=FyYD7D11X2I[/youtube]

Example 2: Control motor speed with pwm

Flow Chart:

Program Code:
#define sw1 8
#define sw2 9
#define sw3 10
#define led1 29
#define led2 28
#define led3 27
int E1 = 12;
int M1 = 7;
int E2 = 13;
int M2 = 4;
void setup() 
{ 
pinMode(M1, OUTPUT);
pinMode(M2, OUTPUT); 
pinMode(E1, OUTPUT);
pinMode(E2, OUTPUT);
pinMode(sw1, INPUT);
pinMode(sw2, INPUT);
pinMode(sw3, INPUT);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT); 
}
unsigned int value;
void loop() 
{
digitalWrite(E1,LOW);
digitalWrite(E2, LOW);
while(1)
{
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
if (digitalRead(sw1) == 0)
{
digitalWrite(led1,HIGH);
value=512;
digitalWrite(M1,HIGH);
digitalWrite(M2, HIGH);
analogWrite(E1, value); //PWM Speed Control
analogWrite(E2, value); //PWM Speed Control
delay(30);
}
else if (digitalRead(sw2) == 0)
{
if (value<1023)
{
digitalWrite(led2,HIGH);
value+=1;
digitalWrite(M1,HIGH);
digitalWrite(M2, HIGH);
analogWrite(E1, value); //PWM Speed Control
analogWrite(E2, value); //PWM Speed Control
delay(30);
}
}
else if (digitalRead(sw3) == 0)
{
if (value>0)
{
digitalWrite(led3,HIGH);
value-=1;
digitalWrite(M1,HIGH);
digitalWrite(M2, HIGH);
analogWrite(E1, value); //PWM Speed Control
analogWrite(E2, value); //PWM Speed Control
delay(30);
}
}
}
}

Demonstration:
[youtube]http://www.youtube.com/watch?v=kmpc8PX44Fw[/youtube]

Buy

, ,

Related Post

Control Mobile Robot through WiFi with ESP-WiFi Shield (Arduino + Andriod)

Arduino + Stepper Motor + 2Amp Motor Driver Shield

Pinguino + XBee Shield

Pinguino + Graphic LCD Shield

Leave a Reply

Your email address will not be published. Required fields are marked *