
140 Make: Wearable Electronics
// set pin as input
// use internal pull-up resistor
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
// read input pin:
buttonValue = digitalRead(buttonPin);
// print button value:
Serial.println(buttonValue);
delay(100);
}
Upload the sketch to your Arduino board. Then, while the board is still
connected via USB, open the Serial Monitor, and you will see the switch
values change as you press and release the button.
When you press the button, the value should change to 0. Otherwise, it will
be 1.
See also Arduino’s “Digital Read Serial” page (docs.arduino.cc/built-in-
examples/basics/DigitalReadSerial).
You’ve now c