Lab Debrief
8 - 40 Gettings Started with the MSP430 - Using Energia (Arduino)
Q&A: Lab8C (3)
Another Pushbutton/Serial Example (StateChangeDetection sketch)
12. Examine the sketch, download and run it.
How is this sketch different? What makes it more efficient?
_____________________________________________________________________
How is this (and all our sketches, up to this point) inefficient?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
It only sends data over the UART whenever the button changes
Our pushbutton sketchs – thusfar – have used polling to determine the state of the
button. It would be more efficient to let the processor sleep; then be woken up by an
interrupt generated when the pushbutton is depressed.
Q&A: Lab8D
Interrupt Example (Interrupt_PushButton)
7. Look up the attachInterrupt() function. What three parameters are required?
1. _____________________________________________________________
2. _____________________________________________________________
3. _____________________________________________________________
8. Compile & download your code and test it out.
Does the green RED_LED flash continuously? _____________________________
When you push the button, does the GREEN_LED light? _____________________
Notes:
Use reset button to start program again and clear GREEN_LED
Most common error, not configuring PUSH2 with INPUT_PULLUP.
Interrupt source – in our case, it’s PUSH2
ISR function to be called when int is triggered – for our ex, it’s “myISR”
Mode – what state change to detect; the most common is “FALLING”