Use the ThinkerShield's pushbutton (D7) to switch the D12 LED on and off — digitalRead and an if/else statement.
From the unit Crack the Code
· activity PRP 2: Digital input — Button
int buttonPin = 7; // the pushbutton is on pin D7 of the ThinkerShield
int ledPin = 12; // the LED is on pin D12
int buttonState = 0; // variable for reading the pushbutton's state
void setup() {
pinMode(ledPin, OUTPUT); // the LED pin is an output
pinMode(buttonPin, INPUT); // the button pin is an input
}
void loop() {
buttonState = digitalRead(buttonPin); // read the button
if (buttonState == HIGH) { // is it pressed?
digitalWrite(ledPin, HIGH); // yes -> LED on
} else {
digitalWrite(ledPin, LOW); // no -> LED off
}
}
Shared from Little Bird Electronics curriculum.