Tilt Switch Reference
A simple ball (or mercury) tilt switch that closes or opens a circuit depending on orientation — a mechanical, single-axis alternative to a full accelerometer.
Pin names
| Name | Description |
|---|---|
| GND | Ground |
| VCC | Power (5V) |
| OUT | Signal — HIGH/LOW depending on tilt orientation |
Attributes
This component has no configurable attributes.
Usage
Connect VCC to 5V, GND to GND, and OUT to a GPIO configured as INPUT.
const int TILT_PIN = 2;
void setup() {
pinMode(TILT_PIN, INPUT);
Serial.begin(9600);
}
void loop() {
int state = digitalRead(TILT_PIN);
Serial.println(state == HIGH ? "Tilted" : "Level");
delay(200);
}
Examples
| Description | Attrs |
|---|---|
| Default tilt switch | {} |
See also
- MPU-6050 IMU — full accelerometer/gyroscope for precise orientation sensing
- Pushbutton — same simple digital switch behaviour, manually triggered