Paso 8: Código para silla de ruedas!!
/*
*
*
*
*
*/
#define m11 5
#define m12 6
#define m21 10
#define m22 11
#define D0 3
#define D1 4
#define D2 7
#define D3 8
forward() vacío
{
digitalWrite (m11, LOW);
digitalWrite (m12, HIGH);
digitalWrite (m21, HIGH);
digitalWrite (m22, LOW);
}
void backward()
{
digitalWrite (m11, HIGH);
digitalWrite (m12, LOW);
digitalWrite (m21, LOW);
digitalWrite (m22, HIGH);
}
left() vacío
{
digitalWrite (m11, HIGH);
digitalWrite (m12, HIGH);
digitalWrite (m21, HIGH);
digitalWrite (m22, LOW);
}
right() vacío
{
digitalWrite (m11, LOW);
digitalWrite (m12, HIGH);
digitalWrite (m21, HIGH);
digitalWrite (m22, HIGH);
}
void Stop()
{
digitalWrite (m11, HIGH);
digitalWrite (m12, HIGH);
digitalWrite (m21, HIGH);
digitalWrite (m22, HIGH);
}
void setup()
{
pinMode (D0, entrada);
pinMode (D1, entrada);
pinMode (D2, entrada);
pinMode (D3, entrada);
pinMode (m11, salida);
pinMode (m12, salida);
pinMode (m21, salida);
pinMode (m22, salida);
}
void loop()
{
int temp1=digitalRead(D0);
int temp2=digitalRead(D1);
int temp3=digitalRead(D2);
int temp4=digitalRead(D3);
Si (temp1 == 0 & & temp2 == 1 & & temp3 == 1 & & temp4 == 0)
Forward();
else if (temp1 == 0 & & temp2 == 0 & & temp3 == 0 & &
Temp4 == 1)
Left();
else if (temp1 == 0 & & temp2 == 1 & & temp3 == 1 & &
Temp4 == 1)
Right();
else if (temp1 == 1 & & temp2 == 0 & & temp3 == 0 & &
Temp4 == 1)
backward();
else if (temp1 == 1 & & temp2 == 1 & & temp3 == 1 & &
Temp4 == 1)
STOP();
}