In my microprocessing class our teacher has made us program a MSP430G2553 to do light up 8 led's in a certain sequence when a button is pressed. The micro is attached to a Breadboard that is then connected to two buttons and the 8 led's. When the power is connected none of the lights will be lit. When one button is pressed a sequence will begin and continue until the person presses both buttons at the same time. The same goes for the second button. I have been able to achieve two of the three parts. The only part I have trouble is getting out of the while loop/pressing the 2 buttons at the same time. I have tried multiple methods but with no results. I have attached the code so you could help me out with this.
p.s. Teacher is horrible assumes everyone in class can already program / no book to read from. Is there any websites/books that I could use to help me understand this material?
/* * main.c */ #include <MSP430G2553.h> #define DELAY 159000 #define DELAY_1 1000000 void main() { WDTCTL = WDTPW+WDTHOLD; P1DIR = 0xFF; P2REN |= (BIT3|BIT4); P2OUT &= (~(BIT3|BIT4)); unsigned int i; while(1) { P1OUT = 0x00; if(P2IN&BIT3) { while(1) { P1OUT = BIT3|BIT4; _delay_cycles(DELAY); P1OUT = BIT2|BIT5; _delay_cycles(DELAY); P1OUT = BIT1|BIT6; _delay_cycles(DELAY); P1OUT = BIT0|BIT7; _delay_cycles(DELAY); } } if(P2IN&BIT4) { while(1) { P1OUT = BIT0|BIT2; for(i=0; i<6; i++) { _delay_cycles(DELAY_1); P1OUT = P1OUT << 1; } P1OUT = BIT7|BIT5; for(i=0; i<6; i++) { _delay_cycles(DELAY_1); P1OUT = P1OUT >> 1; } } } } }