hi
i am making a bluetooh controlled car using arduino. since i am not using the original arduino uno but my own custom board so i made a motor driver shield using l293d but it is behaving strangely! when i turn on the board, it works ok for the first few commands sent over bluetooth (forward etc..) but then the car starts rotating as if i have sent the turn command. to make sure this problem is not due to some code problem, i took the same l293d and tried it on my 433MHz rf controll board ( which uses a ht12d ie i had same four outputs like in the case of a microcontroller and used the rf remote based on ht12e to controll these four outputs with four inputs on ht12e) but still it worked for some time when i started it and again one motor started rotating in wierd manner. i am using two nokia 3.7 volt 1000mAh in series as the power source and the motors are cheap toy motors like this - http://thinkoutofthenet.com/wp-content/uploads/2010/03/dc-toy-motor1.jpg i even connected .1uf caps at the motor terminals to check if it is a noise problem due to those motors but the same result was obtained i read somewhere that the l293d can habdle only 600mA but the ic is not getting hot
UPDATE- i did what nhbill and sheldon said and tested each piece separately, i took out the l293d from the board, tested it on breadboard and found that it is working fine so there is not any problem in motor driver. After this i tested the bluetooth connection and my code and as Birdmun advised, i modified my code so that it sends back what it is receiving over the bluetooth to the serial terminal. here is the code-- (f- move forward, s-stop, b-move backwards, r-right turn, l-left turn)
const int ma1 = 5;
const int ma2 = 7;
const int mb1 = 6;
const int mb2 = 8;
char a;
void setup()
{
Serial.begin(9600);
pinMode(ma1,OUTPUT);
pinMode(ma2,OUTPUT);
pinMode(mb1,OUTPUT);
pinMode(mb2,OUTPUT);
}
void loop()
{
while(Serial.available()>0)
{
a = Serial.read();
Serial.print("\n");
Serial.print(a);
}
switch (a) {
case 'f':
drive(255, 0, 255, 0); //forward
break;
case 's':
drive(0, 0, 0, 0); //stop
break;
case 'l':
drive(128, 1, 128, 0); //left
break;
case 'r':
drive(128, 0, 128, 1); //right
break;
case 'b':
drive(0, 1, 0, 1); //backup
break;
}
}
void drive(int m1spd, boolean m1dir, int m2spd, boolean m2dir)
{
analogWrite(ma1, m1spd);
digitalWrite(ma2, m1dir);
analogWrite(mb1, m2spd);
digitalWrite(mb2, m2dir);
}
now if i send f to move it forwards or b for moving it backwards it works for 5-6 times then the microcontroller sort of "hangs" and the wheels keeps on rotating to move it forward or backward depending on the last character i send and after this either the microcontroller doesn't send anything back to serial or starts sending back random characters and symbols. this problem occurs more often (only works properly once or twice) if i try to turn it (NOTE- i am using PWM while turning to slow down its turning speed)
UPDATE- i added a 100uF cap between the 5 volt and the ground terminals on the l293d, it works properly for more time now ( :D ) but still it is not fully reliable and hangs after about 20 or 30 commands
so is it the noise problem? if it is then what more can i do to dampen this noise?
thanks
sanc04