view code/main.c @ 5:d3a2cbba1eca draft default tip

Add bill of materials
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sun, 21 Oct 2018 14:56:12 +0200
parents 8e98dff12acb
children
line wrap: on
line source

#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>

#define byte unsigned char

#define COL0 PB0
#define COL1 PB4
#define COL2 PB1
#define COL3 PB3
#define COL4 PB2

const byte PROGMEM VALUES[] = {
    (COL0 << 4) | COL4,
    (COL0 << 4) | COL3,
    (COL0 << 4) | COL2,
    (COL0 << 4) | COL1,

    (COL1 << 4) | COL4,
    (COL1 << 4) | COL3,
    (COL1 << 4) | COL2,
    (COL1 << 4) | COL0,

    (COL2 << 4) | COL4,
    (COL2 << 4) | COL3,
    (COL2 << 4) | COL1,
    (COL2 << 4) | COL0,

    (COL3 << 4) | COL4,
    (COL3 << 4) | COL2,
    (COL3 << 4) | COL1,
    (COL3 << 4) | COL0,

    (COL4 << 4) | COL3,
    (COL4 << 4) | COL2,
    (COL4 << 4) | COL1,
    (COL4 << 4) | COL0,
};


int main() {
    while(1) {
        for (byte i=0; i<20; ++i) {
            byte value = pgm_read_byte_near(VALUES + i);
            DDRB = _BV(value & 0x0f) | _BV(value >> 4);
            PORTB = _BV(value >> 4);
            _delay_ms(18);
        }
        DDRB = 0;
        _delay_ms(740);
    }
}