// Jeffery Durand // // v_02: small brightness; if button pressed, brightness higher // // Button PA3 (pin 10) // LED PA7 (pin 6) // Cristal Xtal 1 & 2 (pin 2 & 3) #include // basic library #include /* Functions to waste time */ int main (void) { /* Initialization */ DDRA = 0b10000000; // configure PA7 as output, rest of pins as input PORTA = 0b00001000; // set pull-up resistor at PA3 /* Event Loop */ while (1) { /* action */ if ((PINA & 0b00001000) == 0) // meaning the input on PA3 is low, so ground is connected, so button is pressed { PORTA |= (1 << PA7); // turn the LED pin on } else { PORTA = ~((1 << PA7) | ~PORTA); // turn the led pin off _delay_us(50); PORTA |= (1 << PA7); // turn the LED pin on _delay_us(1); // wait } } return (0); // never reached }