summaryrefslogtreecommitdiff
path: root/hello.c
blob: 2d1ba75347d976e3c08c1325b85a2959625baed6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <avr/io.h>
// F_CPU frequency to be defined at command line
#include <util/delay.h>

// LED is on pin 2, PB3
#define LED      PB3
#define DELAY_MS 500

int main () {
	uint8_t high = 0;
	uint16_t ms = 0;

	DDRB |= (1 << LED);
	PORTB &= ~(1 << LED);

	while (1) {	
		high = !high;

		if (high) {
			PORTB |= (1 << LED);
		} else {
			PORTB &= ~(1 << LED);
		}

		for (ms = DELAY_MS; ms > 0; ms -= 10) {
			_delay_ms(10);
		}
	}

	return 0;
}