blob: 0529721d0a4ba04d7f9118c0d02090cdf7856604 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <avr/wdt.h>
#include <util/delay.h>
#include <stdlib.h>
volatile uint8_t disp[8];
int main (void)
{
wdt_disable();
DDRB = 0xff;
DDRD = 0xff;
PORTB = 0;
PORTD = 0;
TCCR0A = _BV(CS00); // no prescaler (/8 without software prescaler is okay too)
TIMSK0 = _BV(TOIE0); // interrupt on overflow
// smile!
disp[0] = 0x08;
disp[1] = 0x04;
disp[2] = 0x62;
disp[3] = 0x02;
disp[4] = 0x02;
disp[5] = 0x62;
disp[6] = 0x04;
disp[7] = 0x08;
sei();
while (1) {
sleep_enable();
}
return 0;
}
ISR(TIMER0_OVF_vect)
{
static uint8_t active_col = 0;
PORTB = 0;
PORTD = ~disp[active_col];
PORTB = _BV(active_col);
if (++active_col == 8)
active_col = 0;
}
|