Save a life and a project please!!!


hello dears,
sorry doubt,
but dont know mutch programming, i'm art student want works arduino.
i'm trying make second machine. time dc motors.
i follow tutorial http://dqsoft.blogspot.com.br/2012/10/motores-dc-arduino-controlando-um-motor.html
and add 2 buttons. button1 turns motor right , button2 turns motor left.
but have error in code when hit button2 work 1 time. , work again if hit button1.
can me please?

my code:

code: [select]
const int l293_ena2 = 8;
const int l293_inp3 = 9;
const int l293_inp4 = 10;
const int botao = 2;
const int botao2 = 3;

int estadobotao = 0;
int estadobotao2 = 0;

void setup()
{
pinmode (l293_ena2, output);
pinmode (l293_inp3, output);
pinmode (l293_inp4, output);
pinmode(botao,input);
pinmode(botao2,input);

digitalwrite (l293_ena2, low);
digitalwrite (l293_inp3, low);
digitalwrite (l293_inp4, low);
}

void loop ()
{
estadobotao = digitalread(botao);
estadobotao2 = digitalread(botao2);

if (estadobotao == high) {
digitalwrite (l293_ena2, high);
delay (0);
digitalwrite (l293_inp3, high);
delay (5);
digitalwrite (l293_inp3, low);
}


if (estadobotao2 == high) {
digitalwrite (l293_inp4, high);
delay (500);
digitalwrite (l293_inp4, low);
delay (5);
digitalwrite (l293_ena2, low);
}

}

______________________________________________

video
http://www.youtube.com/watch?v=3o6j2xtgcsk

read how use forum sticky post , fix code posting.
a delay of 5 5ms, not long enough motor.


Arduino Forum > Using Arduino > Programming Questions > Save a life and a project please!!!


arduino

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

Rasperry Wifi LAN Controller - Raspberry Pi Forums

Unlock car with bluetooth and car key