Lab 8
8 - 30 Gettings Started with the MSP430 - Using Energia (Arduino)
7. Interrupts Step 3 – Connect the pushbutton to our ISR.
You just need to add one more line of code to your setup() routine, the attachInterrupt()
function. But what arguments are needed for this function? Let’s look at the Arduino
reference to figure it out.
Help Reference
Look up the attachInterrupt() function. What three parameters are required?
1. _______________________________________________________________________
2. _______________________________________________________________________
3. _______________________________________________________________________
One you have figured out the parameters, add the function to your setup() function.
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? ___________________________
When you push reset, the code should start over again. This should turn off the
GREEN_LED, which you can then turn on again by pushing PUSH2.
Note: Did the GREEN_LED fail to light up? If so, that means you are not getting an
interrupt.
First, check to make sure you have all three items – button is configured;
attachInterrupt() function called from setup(); ISR routine that lights the GREEN_LED
The most common error involves setting up the push button incorrectly. The button
needs to be configured with INPUT_PULLUP. In this way, the button is held high
which lets the system detect when the value falls as the button is pressed.
Missing the INPUT_PULLUP is especially common since most Arduino examples –
like the one shown on the attachInterrupt() reference page only show INPUT. This is
because many boards include an external pullup resistor, Since the MSP430
contains an internal pullup, you can save money by using it instead.