2 #include <util/delay.h>
3 #include <avr/interrupt.h>
9 PORTB &= ~(_BV(PB2) | _BV(PB1));
10 DDRB |= _BV(PB2) | _BV(PB1);
13 TCCR0A = _BV(WGM01) | _BV(WGM00);
14 TCCR0B = _BV(WGM02) | _BV(CS00);
21 static void send_byte(unsigned char b)
23 unsigned char i, mask;
28 USICR = _BV(USIWM0) | _BV(USICS0);
30 while (!(USISR & _BV(USIOIF)))
38 while ( (USISR & _BV(USIOIF)) == 0 ) {
39 USICR = _BV(USIWM0) | _BV(USICS1) | _BV(USICLK);
40 USICR = _BV(USIWM0) | _BV(USICS1) | _BV(USICLK) | _BV(USITC);
45 for (i = 0; i < 8; i++) {
46 USICR = _BV(USIWM0) | _BV(USITC);
47 USICR = _BV(USIWM0) | _BV(USITC) | _BV(USICLK);
52 for (i = 0; i < 8; i++) {
53 PORTB &= ~_BV(PB2); // clock low
54 if (b & 0x80) // data bit on or off
59 PORTB |= _BV(PB2); // clock high
66 PORTB &= ~_BV(PB2); // clock low
70 void send_rgb(unsigned char r, unsigned char g, unsigned char b)
82 for (i = 0; i < STRIP_SIZE; i++) {