/** * Simple lego power function remote control * * Inspired by the work of Sivan Toledo * http://www.tau.ac.il/~stoledo/lego/AVR-ir/ * * 2007, Pat Hanrahan, hanrahan@cs.stanford.edu * */ #include #include /* attiny13 pinout for remote control +--------------+ reset | 1 pb5 vcc 8 | back | 2 pb3 pb2 7 | forw right | 3 pb4 pb1 6 | left | 4 gnd pb0 5 | oc0a -> irled +--------------+ */ #define PININ (_BV(1)|_BV(2)|_BV(3)|_BV(4)) #define LEFT _BV(1) #define FORW _BV(2) #define BACK _BV(3) #define RIGHT _BV(4) /* * */ void setup(void) { // PB0 is outout DDRB = _BV(0); // Pull-up input pins PORTB = PININ; // 9600000/8 Hz / (2 * 16) = 37500 Hz OCR0A = 16; // toggle output compare A (=PB0) TCCR0A = (1 << COM0A0)|(1<