Question: [10] 1) The following program is the simple I/O sample program (Ch8) we discussed in class. Basically when you push the button, LED1 toggles, and
![[10] 1) The following program is the simple I/O sample program](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f51d8326224_90666f51d82cd852.jpg)
[10] 1) The following program is the simple I/O sample program (Ch8) we discussed in class. Basically when you push the button, LED1 toggles, and when you release it, LED2 toggles. Modify the program, so that at the push of the button, the micro cycles through 4 different as follows: 1- LED1 flashes while LED2 off 2- LED2 flashes while LED1 off 3-LED1 and LED2 flash simultaneously 4-LED1 and LED2 flash alternatively Hint: use a counting semaphore to cycle through 4 different values, each of which corresponds to the four different modes, See the other sample code for flasher with multiple speeds Run the program in the lab and have it graded by TA. #include #include "msp430g2553.h" int sw2-0; int main(void) WDTCTL = WDTPw/ WDTHOLD; //stop watchdog timer PI DIR = 0x00; P1DIR (BITO | BIT6); PIREN BIT3; PIOUTBIT3; //port 1 all inputs //set P1.0 and P1.6 as outputs (LED1, LEd2) //activate resister on P1.3 //make it pull up because SW2 is active low For (;;) { sw2 = PI IN; //read values from P1 //mask out only BIT3 where SW2 is connected sw2 &- BIT3 if (sw2 BIT3) //if SW2 is high //turn LED2 off //toggle LED1 //d Pl OUT &--BIT6: P1 OUT -BITO: delay_cycles(50000); elay 50,000 micro seconds else //else (SW2 is low) //turn LED1 off //toggle LED2 //delay 200,000 micro seconds PI OUT &= ~BITO; P1OUT- BIT6; delay_cycles(200000); // end of infinite loop //end of main [10] 1) The following program is the simple I/O sample program (Ch8) we discussed in class. Basically when you push the button, LED1 toggles, and when you release it, LED2 toggles. Modify the program, so that at the push of the button, the micro cycles through 4 different as follows: 1- LED1 flashes while LED2 off 2- LED2 flashes while LED1 off 3-LED1 and LED2 flash simultaneously 4-LED1 and LED2 flash alternatively Hint: use a counting semaphore to cycle through 4 different values, each of which corresponds to the four different modes, See the other sample code for flasher with multiple speeds Run the program in the lab and have it graded by TA. #include #include "msp430g2553.h" int sw2-0; int main(void) WDTCTL = WDTPw/ WDTHOLD; //stop watchdog timer PI DIR = 0x00; P1DIR (BITO | BIT6); PIREN BIT3; PIOUTBIT3; //port 1 all inputs //set P1.0 and P1.6 as outputs (LED1, LEd2) //activate resister on P1.3 //make it pull up because SW2 is active low For (;;) { sw2 = PI IN; //read values from P1 //mask out only BIT3 where SW2 is connected sw2 &- BIT3 if (sw2 BIT3) //if SW2 is high //turn LED2 off //toggle LED1 //d Pl OUT &--BIT6: P1 OUT -BITO: delay_cycles(50000); elay 50,000 micro seconds else //else (SW2 is low) //turn LED1 off //toggle LED2 //delay 200,000 micro seconds PI OUT &= ~BITO; P1OUT- BIT6; delay_cycles(200000); // end of infinite loop //end of main