Question: write a code that s1(push button p1.1) turns LED1 (red led p1.0) on when you push once and turns it off when you push 3

write a code that s1(push button p1.1) turns LED1 (red led p1.0) on when you push once and turns it off when you push 3 times. this should repeat forever.

I alrady did the first part and I want you to do the second part for (turns it off when you push 3 times) using the same code I have.

----------------------------------------------------------------------------------------------------- #include #define RED_LED 0x0001 // P1.0 is the Red LED #define CLEAR_RED_LED 0x00FE // Used to turn off the Red LED #define BUTTON11 0x0002 // P1.1 is the button #define DEVELOPMENT 0x5A80 // Stop the watchdog timer #define ENABLE_PINS 0xFFFE // Required to use inputs and outputs main() { WDTCTL = DEVELOPMENT; // Need for development mode PM5CTL0 = ENABLE_PINS; // Prepare pins for I/O usage P1DIR = RED_LED; // Pin connected to red LED // will be an output P1OUT = BUTTON11; // Button needs a pull-up resistor P1REN = BUTTON11; while(1) // Keep looping forever { while((BUTTON11 & P1IN) == 0) // Is P11 button pushed? { P1OUT = P1OUT | RED_LED; // Turn on the Red LED } P1OUT = P1OUT; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Question One of the resource consum... View full answer

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!