LED1_DDR = 1; LED2_DDR = 1; LED3_DDR = 1; BUTTON1_DDR = 0; BUTTON2_DDR = 0; BUTTON3_DDR = 0; POCR_PAP = 1; // turn on Port A pullups LED1 = ON; Delay(0x1000); LED1 = OFF; LED2 = ON; Delay(0x1000); LED2 = OFF; LED3 = ON; Delay(0x1000); LED3 = OFF; for (;;) // main loop { if (BUTTON1 == CLOSE) // mode switch depressed— { button1_flag = 1; // button1 successfully pressed LED1 = ON; } else { button1_flag = 0; // button1 successfully released LED1 = OFF; } if (BUTTON2 == CLOSE) // mode switch depressed– { button2_flag = 1; // button2 successfully pressed LED2 = ON; } else { button2_flag = 0; // button2 successfully released LED2 = OFF; } if (BUTTON3 == CLOSE) // mode switch depressed˜ { button3_flag = 1; // button3 successfully pressed LED3 = ON; } else { button3_flag = 0; // button3 successfully released LED3 = OFF; } } // end for() loop
#define BUTTON1 PTA_PTA4#define BUTTON2 PTA_PTA5#define BUTTON3 PTA_PTA6#define BUTTON1_DDR DDRA_DDRA4#define BUTTON2_DDR DDRA_DDRA5#define BUTTON3_DDR DDRA_DDRA6 #define LED1 PTD_PTD0 #define LED2 PTD_PTD1 #define LED3 PTD_PTD2 #define LED1_DDR DDRD_DDRD0 #define LED2_DDR DDRD_DDRD1 #define LED3_DDR DDRD_DDRD2
You would be right. Very silly mistake -- I wasn't actually running the init portion. Duh!
Well I would suggest that you are never even executing this code.