Professional Documents
Culture Documents
#include<avr/io.h>
#include<util/delay.h>
int main(void)
{
DDRD=0x00; // PORTD declared as input port
PORTD=0xFF; // PORTD Pull Ups enabled initialized
DDRC=0XFF; // PORTC declared as output port
PORTC=0x00; // PORTC initialized
while(1)
{
if(!(PIND&0x01)) // PIN D0 is used as input
{
_delay_ms(50); // Debounce time
while(!(PIND&0x01));
PORTC=0b00000010; // motor rotates in one particular
direction
}
else
{
PORTC=0x00; // Stop motor
} // else end here
} // While(1) ends here
} // main() ends here
devesh@electroons.com
Best viewed at Firefox 1024x768 resolution