Tilt Sensor Experiments

After completing the Tilt Sensor project, test yourself by trying these experiments.

1 The tilt sensor connections are exactly the same as the push button connections. Push button schematic
To simplify the connections (just like with the push button) we can use the internal pull-down resistor instead of the external resistor. Built-in pull-down resistor












To use the internal pull-down resistor, add a
    digitalWrite(tiltSensor, LOW)
command.
int tiltSensor = 2;
int led = 13;

void setup() {
  pinMode(led, OUTPUT);
  pinMode(tiltSensor, INPUT);
  digitalWrite(tiltSensor, LOW); // use internal pull-down resistor
}

void loop() {
  int tiltState = digitalRead(tiltSensor);
  digitalWrite(led, tiltState);
  delay(10);
}
Remove the external 22K ohm resistor and the wire that connects the resistor to GND on the breadboard and then run your modified program.
You should get the same result.
2 Create a device that will sound an audible alarm and flash a red warning light when an object has fallen over. Hint: Combine a tilt sensor, buzzer, and a red LED.