Save a life and a project please!!!

Hello dears, sorry about my doubt, but i dont know mutch about programming, i'm a art student that want works with Arduino. i'm trying make my second machine. This time with DC Motors. i follow this tutorial http://dqsoft.blogspot.com.br/2012/10/motores-dc-arduino-controlando-um-motor.html and add 2 buttons. button1 turns the motor to right and button2 turns motor to left. but have some error in my code that when i hit the button2 just work one time. and just work again if i hit the button1. can anyone help me please?

my code:

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 the how to use this forum sticky post and fix that code posting. A delay of 5 is only 5mS, not long enough to do anything with a motor.

i put 5ms in button1 and works fine. so organic... in button2 i put 500ms just to better see in video example. :(

Grumpy_Mike: Read the how to use this forum sticky post and fix that code posting.

When you push button 2 the ENA2 line is made LOW after the motor moves and is never made HIGH again, so the motor is disabled until you press button 1 or reset the program.

Your code for button2 appears to turn off the chip enable line at the end. Hence nothing happens until you re-enable it at the beginning of your button1 code.

Edit: ninja'd

Many thanks for the fast response.. Thats right.. i found the error and this code below works very fine!

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); }
else
{
if (estadoBotao2 == HIGH) 
{
digitalWrite (L293_INP4, HIGH); 
delay (5); 
digitalWrite (L293_INP4, LOW); 
delay (0); 
digitalWrite (L293_ENA2, HIGH); 
}
else
{
digitalWrite (L293_INP4, LOW); 

digitalWrite (L293_INP4, LOW); 
digitalWrite (L293_ENA2, LOW); 
}}}

but now, i have other doubt. how i do to add more one motor and more 2 buttons? i have no idea :/

how i do to add more one motor and more 2 buttons?

The simplest way is to repeat the code inside the loop() function.