timer_shift_PWM.c
and mood_ring.c
files.For Lab 2, you figured out how to run your MSP430 in Low Power Mode. In order to make your mood ring, you’ll need to properly architect your code. To begin with, think about the different time scales at which you want to act:
main()
function contains an instruction which puts the CPU into a low power mode,
what are the minimal interrupt service routine instructions required to wake the CPU and return
function to the main()
function?You can either use two separate LEDs or an RGB LED unit soldered to a breakout board for the
rest of Part 1. Modify your code from Lab 2 so that the main()
function adjusts the PWM
parameters to increase the brightness of the blue LED and decrease the brightness of the red
LED through 16 levels (so that maximum blue corresponds with minimum red and vice versa). Your
main()
function should be an infinite loop, with a command to go into low power mode at the end
of each color shift cycle. Set up the WDT+ module to generate an interrupt every second to wake
up the CPU, so that the shifts in color happen every second.
Save this code as timer_shift_PWM.c. You will create a demo video which contains both the timer-shifted colors and temperature shifted colors.
In this part, we’ll put together Part 1 and add in ADC to make a “mood ring” with the RGB LED (ignoring the green part) controlled by the on board temperature sensor. We’ll start off with a few questions that should guide learning how to use ADC:
Modify your main()
function so that the code goes into low power mode twice: after enabling
the ADC10 to sample and after changing the PWM parameters for the LEDs. Set up your ISRs for
the ADC10 and WDT interrupts to return control to the main()
function, with the WDT interrupt
executing at 4 Hz. Once you receive a sample temperature, you should scale your LED output so
that cold will be fully blue and hot will be fully red. (You can play around with “hot” and
“cold” values, try to get them to a range where if you warm your hands and touch the MSP it’s
“hot” and if you don’t touch it for a while or actively cool it it’s “cold”.)This is now the
code for your “mood ring” on your breadboard. Make sure to comment your code in detail, such
that any design decisions you made are easily available (which components are on which pins,
label interval for timers in ms, etc). Save this code as mood_ring.c
. Create a demo video that
shows the timer-shifting colors from Part 1 and temperature shifting color from Part 2. For
Part 2, you should start with your device at one extreme, change it to the other, and then let
it return. Upload your answered questions, code and the video URL to Canvas.
Bonus: Add a “heart-beat” functionality to your mood ring where the LEDs flash at 0.5 Hz, but rather than flashing, become dimmer and brighter smoothly, with the color corresponding to the temperature.