Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

BLINKING LED SEQUENCE Use the IAR IDE tool and the LaunchPad board with the MSP430G2553 device to do the following: create a C language program

BLINKING LED SEQUENCE

Use the IAR IDE tool and the LaunchPad board with the MSP430G2553 device to do the following: create a C language program to operate with the LaunchPad board.

Leftmost Pushbutton (P1.3) has NOT been pressed:

The RED and GREEN LEDs are both OFF Leftmost Pushbutton pressed briefly, then released:

For the second part: The Leftmost Pushbutton (P1.3) is pressed briefly, then released:

you will need to use the assigned two-digit number. Both LEDs will be OFF initially. The GREEN LED (P1.6) will turn ON, then OFF, such that it turns ON the number of times for the 1s digit of the assigned number for this program. AFTER the GREEN LED has completed its sequence and is in the OFF state, then the RED (P1.6) LED will turn ON, then OFF, such that it turns ON the number of times for the 10s digit of the number assigned to you for this project.

Timing: GREEN LED(P1.6) turns ON for approximately 500 mS, then OFF for approximately 500 mS until it has completed its proper count, then it turns OFF and stays OFF.

Then the RED LED (P1.0) turns ON for approximately 1 full second, then OFF for approximately 1 full second until it has completed its proper count, then it turns OFF and stays OFF. Now, both LEDs will be OFF, unless the leftmost pushbutton is pressed again.

If the pushbutton is pressed again after the above sequence completes, the sequence will repeat. The pushbutton does not have to do anything except when both LEDs are OFF, either at the very beginning or after the blink sequence has completed.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

NOTE: the timing of the sequence is fine. but I can't get my pushbutton to work, and the sequence continues to repeat itself. I really need help.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#include

#define BUTTON BIT3 // Port 1.3

#define RED_LED BIT0 // Port 1.0

#define GREEN_LED BIT6 // Port 1.6

void main (void) {

// Watchdog setup

WDTCTL = WDTPW + WDTHOLD; // stop using the watchdog

// LED initial setup

P1DIR |= RED_LED + GREEN_LED; // ENABLE GREEN AND RED LED

// Button setup

P1DIR &= ~BUTTON; // button is an input

P1OUT |= BUTTON; // pull-up resistor

P1REN |= BUTTON; // resistor enabled

P1OUT &= ~RED_LED; // Red off

P1OUT &= ~GREEN_LED; // Green off

while(1){

if (P1IN & BUTTON) {

P1OUT |= GREEN_LED; // Green on

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

P1OUT &= ~GREEN_LED; // Green off

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

P1OUT |= GREEN_LED; // Green on

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

P1OUT &= ~GREEN_LED; // Green off

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

P1OUT |= GREEN_LED; // Green on

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

P1OUT &= ~GREEN_LED; // Green off

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

P1OUT |= RED_LED; //Red on

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

P1OUT &= ~RED_LED; // Red off

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

P1OUT |= RED_LED; //Red on

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

P1OUT &= ~RED_LED; // Red off

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

for(int i = 0; i < 30000;i++); // delay for a while

P1OUT &= ~RED_LED; // Red off

P1OUT &= ~GREEN_LED; // Green off

} else {

P1OUT &= ~RED_LED; // Red off

P1OUT &= ~GREEN_LED; // Green off

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 2 Lncs 13427

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124251, 978-3031124259

More Books

Students also viewed these Databases questions

Question

What are the four essential qualities of an opportunity?

Answered: 1 week ago

Question

Determine the roles of spatial layout and functionality.

Answered: 1 week ago