Professional Documents
Culture Documents
5-10-07
Copyright Spark Fun Electronics 2007
Nathan Seidle
nathan at sparkfun.com
ATmega168
Example Blink
Toggles all IO pins at 1Hz
Group Members: Bryan Poole, Ryan Praytor, Brian Rankin
*/
#include <avr/io.h>
//Define functions
//======================
void ioinit(void);
//Initializes IO
while(1)
{
//0
PORTB = 0x00;
PORTC = 0x00;
PORTD = 0x00;
delay_ms(500);
//one
PORTB = 0xFF;
PORTC = 0x00;
PORTD = 0x00;
delay_ms(500);
PORTC = 0x00;
PORTB = 0x00;
PORTD = 0x00;
delay_ms(500);
//2
PORTB = 0x00;
PORTC = 0x00;
PORTD = 0xFF;
delay_ms(500);
PORTC = 0x00;
PORTB = 0x00;
PORTD = 0x00;
delay_ms(500);
//3
PORTB = 0xFF;
PORTC = 0x00;
PORTD = 0xFF;
delay_ms(500);
PORTC = 0x00;
PORTB = 0x00;
PORTD = 0x00;
delay_ms(500);
//4
PORTB = 0x00;
PORTC = 0xFF;
PORTD = 0x00;
delay_ms(500);
PORTC = 0x00;
PORTB = 0x00;
PORTD = 0x00;
delay_ms(500);
//5
PORTB = 0xFF;
PORTC = 0xFF;
PORTD = 0x00;
delay_ms(500);
PORTC = 0x00;
PORTB = 0x00;
PORTD = 0x00;
delay_ms(500);
//6
PORTB = 0x00;
PORTC = 0xFF;
PORTD = 0xFF;
delay_ms(500);
PORTC = 0x00;
PORTB = 0x00;
PORTD = 0x00;
delay_ms(500);
//7
PORTB = 0xFF;
PORTC = 0xFF;
PORTD = 0xFF;
delay_ms(500);
PORTC = 0x00;
PORTB = 0x00;
PORTD = 0x00;
delay_ms(1000);
}
return(0);
}