Rev 495 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download
#include <avr/io.h>#include <inttypes.h>#define F_CPU 1000000UL // 1 MHz#include <util/delay.h>void delay_ms(unsigned int ms)/* delay for a minimum of <ms> */{// we use a calibrated macro. This is more// accurate and not so much compiler dependent// as self made code.while(ms){_delay_ms(0.96);ms--;}}/* new style */int main(void){/* INITIALIZE *//* enable PC5 as output */DDRC|= (1<<DDC5);/* PC5 is 5 (see file include/avr/iom8.h) and 1<<PC5 is 00100000* This can also be written as _BV(PC5)*/while (1) {/* led on, pin=0 */PORTC &= ~(1<<PC5);delay_ms(100);/* set output to 5V, LED off */PORTC|= (1<<PC5);delay_ms(1000);}return(0);}