/* * MIC-Week1.c * * Created: 2-2-2016 11:48:44 * Author : kenny */ #define F_CPU 8000000UL #define NELEMS(x) (sizeof(x) / sizeof(x[0])) #include #include #include int reset = 0; /******************************************************************/ void wait( int ms ) /* short: Busy wait number of millisecs inputs: int ms (Number of millisecs to busy wait) outputs: notes: Busy wait, not very accurate. Make sure (external) clock value is set. This is used by _delay_ms inside util/delay.h Version : DMK, Initial code *******************************************************************/ { for (int i=0; i 4000) { blink = 4000; } } int main(void) { DDRC = 0b00000000; //input DDRD = 0b11111111; //output // Prescaler = FCPU/8000000 TCCR0 |= (1 << CS01) | (1 << CS00); //Enable Overflow Interrupt Enable TIMSK|=(1<= 0x80) { PORTD= 0x1; } else { PORTD = (PORTD<<1); } } void opgave5(void) { if(PINC != 0 ) { speed = PINC; } // Write data to PORTD PORTD = pattern[count].data; // wait wait(pattern[count].delay * speed); count++; if(count >= NELEMS(pattern)) { count = 0; } } void opgave6(void) { PORTD = 0b10000000; wait( blink ); PORTD = 0b00000000; wait( blink ); }