Back
/*********************************************************************
xBoard(TM) v2.0 Sample Programs
------------------------------------
Description : Simple Motor Control Demo.
Start Motor A in Clockwise direction.
Then Stops the Motor
Again Starts the Motor in Counter Clockwise Direction.
Notes: Jupmer JP2 Must be in OFF position.
This means NO SPEED Control.
Author : Avinash Gupta 2008
Web : www.eXtremeElectronics.co.in
**********************************************************************/
#include <avr/io.h>
#include <util/delay.h>
void Wait()
{
uint8_t i;
for(i=0;i<80;i++)
_delay_loop_2(0);
}
void main()
{
//First Set up I/O Ports as OUTPUT
//PC0 and PC1 as output
DDRC|=((1<<PC0)|(1<<PC1));
//Repeat the sequence forever
while(1)
{
//Clockwise Motion
PORTC|=(1<<PC0); //PC0 = HIGH
PORTC&=(~(1<<PC1)); //PC1 = LOW
Wait();
//Stop
PORTC&=(~(1<<PC0)); //PC0 = LOW
PORTC&=(~(1<<PC1)); //PC1 = LOW
Wait();
//Counter Clock Wise Motion
PORTC&=(~(1<<PC0)); //PC0= LOW
PORTC|=(1<<PC1); //PC1= HIGH
Wait();
//Stop
PORTC&=(~(1<<PC0)); //PC0 = LOW
PORTC&=(~(1<<PC1)); //PC1 = LOW
Wait();
}
}
Top |