Parts
-Arduino microcontroller and carrier board
-LiPo battery
-Bump sensor
Prepare the breadboard
Solder wire to NO (normally open) and C (common) switch terminals. Then when switch is pressed, circuit is closed (like a pushbutton). Follow code (below) in File:Examples:Digital:Button. Use breadboard to mount 10K resistor (brown, black, orange); see diagram and photo. Verify when switch is pressed, LED lights up.
Program the Microcontroller
int buttonState=0;#define buttonPin 3
void setup() { pinMode(buttonPin, INPUT); Serial.begin(9600); delay(25);}void loop(){ // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); if (buttonState == HIGH) Serial.println("button pressed"); else Serial.println("not pressed");}