3 #include <avr/interrupt.h>
6 void wait_until_key_pressed(void)
8 unsigned char temp1, temp2;
12 temp1 = PINC; // read input
14 temp2 = PINC; // read input
15 temp1 = (temp1 & temp2); // debounce input
16 } while ( temp1 & _BV(PINC4) );
18 loop_until_bit_is_set(PINC,PINC4); /* wait until key is released */
23 // configure to read center press on joy switch
24 DDRC &=~ (1 << PC4); /* Pin PC4 input */
25 PORTC |= (1 << PC4); /* Pin PC4 pull-up enabled */
27 for (;;) { /* loop forever */
28 // turn on LCD backlight LED
30 wait_until_key_pressed();
32 wait_until_key_pressed();