Question: Switches control LED2. 1. Create a new project Lab6a. Copy in your code from Lab 5 that blinked LED1 based on Timer A. Add to

Switches control LED2. 1. Create a new project Lab6a. Copy in your code from Lab 5 that blinked LED1 based on Timer A. Add to your program by making LED2 illuminate whenever either the left button (S1) or right button (S2) is pressed. LED2 should stay on only as long as the button remains pressed.

this is lab 5:

#include // LED P1.0 void main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer PM5CTL0 = 0xFFFE; // to enable inputs and outputs //set up LED P1OUT&=~BIT0; // for LED1 set P1.0 to output P1DIR|=BIT0; // turn on LED1 //set up Timer A0 TA0CTL|=TASSEL_1|MC_1|TACLR; //ACLK, count up TA0CCR0=0x8000; //Limit 0x8000 = 32768 // infinite loop for (;;) { if(TA0CTL&TAIFG) //If flag is set from count up { P1OUT^=BIT0; //toggle LED TA0CTL&=~BIT0; //reset flag } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!