Lab Debrief
8 - 38 Gettings Started with the MSP430 - Using Energia (Arduino)
Q&A: Lab8B (1)
2. Try out the sketch.
When you push the button the (GREEN or RED) LED goes (ON or OFF)?
_________________________________________________
Examine the code
3. How is the LED defined differently in the ‘Button’ Sketch versus the ‘Blink’ sketch?
_____________________________________________________________________
_____________________________________________________________________
4. How is the pushbutton created/used differently from the LED?
_____________________________________________________________________
What “Energia” pin is the button connected to? _______________________________
What is the difference between INPUT and INPUT_PULLUP?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Green LED goes OFF
In ‘Blink’, the LED was #defined (as part of Energia);
in ‘Button’, it was defined as a const integer. Both work equally well.
In Setup() it is configured as an ‘input’; in loop() we use digitalRead()
P1_1
INPUT config’s the pin as a simple input – e.g. allowing you to read pushbutton.
Using INPUT_PULLUP config’s the pin as an input with a series pullup resitor;
(many TI C provide these resistors as part of their hardware design).
Q&A: Lab8B (2)
5. Just like standard C code, we can create variables. What is the global variable used
for in the ‘Button’ example?
_____________________________________________________________________
_____________________________________________________________________
What would be a more efficient way to handle responding to a pushbutton? (And why
would this be important to many of us MSP430 users?)
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
(Note, we will look at this later.)
Reverse Button/LED action
8. Did it work? _________________
‘buttonState’ global variable holds the value of the button returned by digitalRead().
We needed to store the button’s value to perform the IF-THEN/ELSE command.
It would be more efficient to let the button ‘interrupt’ the processor, as opposed to
reading the button over and over again. This is as the processor cannot SLEEP
while polling the pushbutton pin. If using an interrupt, the processor could sleep until
being woken up by a pushbutton interrupt.
Yes (it should)