U23 2008/Gruppe1
< U23 2008
Revision as of 21:16, 18 August 2008 by 87.79.236.180 (talk) (New page: #include <avr/io.h> #include <util/delay.h> void lampe(uint8_t l) { switch (l) { case 0: PORTC ^= _BV(PC4); break; case 1: PORTD ^= _BV(PD3); break; case 2: PORT...)
#include <avr/io.h> #include <util/delay.h> void lampe(uint8_t l) { switch (l) { case 0: PORTC ^= _BV(PC4); break; case 1: PORTD ^= _BV(PD3); break; case 2: PORTD ^= _BV(PD6); break; case 3: PORTD ^= _BV(PD7); break; default: break; } } void main(void) { /* config PD7 as output */ DDRC = _BV(PC4); DDRD = _BV(PD3) | _BV(PD6) | _BV(PD7); uint8_t ls[] = {0, 1, 0, 2, 1, 3, 2, 1, 3}; uint8_t p=0; while(1) { //PORTD ^= _BV(PD7); uint8_t i; lampe(ls[p]); p++; for (i = 0; i < 76; i++) { /* wait 4 * 65536 cycles */ _delay_loop_2(0); } } for ( ;; ) ; }