Question: Educational Objective: The educational objective of this laboratory assignment is to gain experience programming the I / O pins on the TI MSP 4 3

Educational Objective:
The educational objective of this laboratory assignment is to gain experience programming the I/O pins on the TI MSP430 microcontroller. The objective will be met by writing code that emulates the operation of a multi-function flashlight.
The multi-function flashlight works as follows:
- The first time the power button is pushed, the LEDs turn on yellow
- The second time the power button is pushed, the LEDs turn on red
- The third time the power button is pushed, the LEDs flash green
- The fourth time the power button is pushed, the LEDs turn off *note that in a real flashlight the LEDs would be white, but we are using the expansion board that came in your kit
Background:
On the expansion board there are three clear LEDs that are able to display red, green or yellow. We will use these LEDs for this lab. The two LEDs that are parallel to the bottom of the board are referred to as main. They are tied together, and thus, controlled by the same pins. The other LED is referred to as side. The pinout for the
There are two pushbuttons on the board and we will be using the one on the top of the board, labeled 'car'. This pushbutton is connected to pin P2.1. The pushbutton is active low, meaning it drives a 1 in the resting state and a 0 when it is pushed.
Pre-Laboratory:
1. Read and follow the prelab instructions very carefully.
2. Review lectures 18,19 and 20 posted in MyCourses.
3. Open a new project in Code Composer Studio
4. Write the code for the Multi-Function Flashlight described above. You can use the outline (lab9.c) posted in Mycourses as a guide if you would like.
5. Pay close attention to lecture 20 for reading the input pushbutton
6. The code must be written using bit masking ```
`//**************************************************************//
|// CPET133 Lab9- MultiFunction Flashlight
//
// Jeanne Christman
// original version 11/15/2024
//
// this program functions as a multi-function flashlight
//-on the first button push the LEDs turn on yellow
//-on the second button push the LEDs turn on red
//-on the third button push the LEDs flash on and off (green)
//-on the fourth button push the LEDs turn off
//This program uses the ECTET breakout board with the TI MSP430 LaunchPad
//
//The LEDs used are the three multi-colored ones and the pushbutton used
//pushbutton used is the one labelled 'CAR'
//*****************************************************************//
`#include //for the MSP430 microcontroller
|#include //for integer types
##include //for boolean types
`void main()
{
uint8_t ButtonCount =0; // declare variable to track button pushes
volatile uint16_t i; // iteration counter for delay loop
WDTCTL = WDTPW | wDTHOLD; // stop watchdog timer
PHSCTLO &= ~LOCKLPM5; // always include these two lines
//Configure the port pins as inputs and outputs (use bitmasking)
//turn all of the LEDs off (use bitmasking)
while(1){//run code in an endless loop
if (){//check if button is pushed (0) and do the following - see lecture 20
; //increment count on each push
if (){//if count ==4, set it back to 0 and turn off all LEDs
;
}
while (){}//wait here until button is released - see lecture 20
}
//turn on different lights based on button count
if (){//turn on yellow LEDs if count ==1
;
}
else if (){//turn off yellow LEDs, turn on red LEDs if count ==2
;
}
else if (){//turn off red LEDs, toggle green LEDs if count ==3
; ;
;
; //empty for loop for delay
}
}
return;
``` Educational Objective:
The educational objective of this laboratory assignment is to gain experience programming the I/O pins on the TI MSP430 microcontroller. The objective will be met by writing code that emulates the operation of a multi-function flashlight.
The multi-function flashlight works as follows:
- The first time the power button is pushed, the LEDs turn on yellow
- The second time the power button is pushed, the LEDs turn on red
- The third time the power button is pushed, the LEDs flash green
- The fourth time the power button is pushed, the LEDs turn off *note that in a real flashlight the LEDs would be white, but we are using the expansion board that came in your kit
Background:
On the expansion board there are three clear LEDs that are able to display red, green or yellow. We will use these LEDs for this lab. The two LEDs that are parallel to the bottom of the board are referred to as main. They are tied together, and thus, controlled by the same pins. The other LED is referred to as side. The pinout for the
There are two pushbuttons on the board and we will be using the one on the top of the board, labeled 'car'. This pushbutton is connected to pin P2.1. The pushbutton is active low, meaning it drives a 1 in the resting state and a 0 when it is pushed.
Pre-Laboratory:
1. Read and follow the prelab instructions very carefully.
2. Review lectures 18,19 and 20 posted in MyCourses.
3. Open a new project in Code Composer Studio
4. Write the code for the Multi-Function Flashlight described above. You can use
Educational Objective: The educational objective

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 Programming Questions!