I guess you are right. I figured out that now.
But I am not that good with programming and I am still learning. Its my second project; first was blinky!
So I tried another code .. it is :
________________________________________
// Blinky_modified to motor cntrol.c
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
// set PORTD for output
DDRD = 0xFF;
// Set Port B for output.
DDRB = 0xFF;
while(1)
{
PORTD = 0x01;
_delay_loop_2(30000);
_delay_loop_2(30000);
PORTD=0x00;
_delay_loop_2(30000);
_delay_loop_2(30000);
PORTB = 0x01;
_delay_loop_2(30000);
_delay_loop_2(30000);
PORTB = 0x00;
_delay_loop_2(30000);
}
}
_____________________________________________________
Stripping of all If's and for loops; I figured out if I provide a switch at the Vcc or AVcc of the Atmega, then turning it on and off would eliminate of getting an input from Pin28 of port C. But this is only the trick. I must rely on this till I learn programming properly!
Now the trouble is ...
While testing the code I used LEDs instead of motors at the L293D output pins, and the code worked fine. The LEDs were blinking for the time for which the motors should run i.e. alternatively; and I was glad for that. But as soon as I connected a motor across the output terminals of L293D (Pin 11 and 14), parallel to LEDs, it works fine for a few moments and after that either both LEds turn on or Either one glows continously .. and the one having a motor parallel to LEDs stops glowing.
The motor I am using is "DVD motor 5.9V ; code: RF-300C-12350 "
I am using "6F22,9V Alkaline" batteries.
here is the Schematic
The whole circuit works well with a single 9v battery (which now gives 7.5v because its used up) but the whole circuit gives the same above mentioned problem when I apply a higher voltage using two batteries to the 8th Pin of L293D ( The Vc Pin). Vcc is supplied with 5v using a 7805 voltage regulator. I have seperately checked the 7805 and it works fine.
Where am I going wrong? Any idea?
Pls. I need to get this done quick !
Help me out guys !
Rahul.