// Jeffery Durand // // v_03: Same POV idea, but different syntax // // Button PA3 (pin 10) // LED PA7 (pin 6) // Cristal Xtal 1 & 2 (pin 2 & 3) #include // basic library #include /* Functions to waste time */ // bitwise manipulations ! (though for several at a time the explicit manipulation is nice) // WARNING: no spacing between the name and params: BIT (x) will crash #define BIT(x) (1 << x) #define bit_get(p,x) (p & BIT(x)) // to read: makes all zero except wanted bit x #define bit_set(p,x) (p |= BIT(x)) // assign a 1 to wanted bit x #define bit_clear(p,x) (p &= ~BIT(x)) // assign a 0 to wanted bit x int main (void) { /* Initialization */ bit_set (DDRA, PA7); bit_set (PORTA, PA3); /* Event Loop */ while (1) { /* action */ if (bit_get(PINA, PA3) == 0) // meaning the input on PA3 is low, so ground is connected, so button is pressed { bit_set (PORTA, PA7); // turn the LED pin on } else { bit_clear (PORTA, PA7); // turn the led pin off _delay_us(50); bit_set (PORTA, PA7); // turn the LED pin on _delay_us(1); // wait } } return (0); // never reached }