Sensor Digital

Tilt Switch

A tilt switch is a simple orientation sensor. In this kit it is a ball-type switch with a metal ball inside.

Part images

Tilt switch. A metal ball closes the contact when the switch is tilted. Image source: SunFounder Pico 2 W Starter Kit documentation, Components section, © 2026 SunFounder.
Tilt switch symbol. SunFounder symbol for the ball-style tilt switch. Image source: SunFounder Pico 2 W Starter Kit documentation, Components section, © 2026 SunFounder.
KY-020 Module Photo. Module Photo for the KY-020 Tilt Switch Module. Image source: Joy-IT SensorKit KY-020 module documentation
KY-020 Pinout / Module Diagram. Pinout / Module Diagram for the KY-020 Tilt Switch Module. Image source: Joy-IT SensorKit KY-020 module documentation
KY-020 Arduino Wiring Diagram. Arduino Wiring Diagram for the KY-020 Tilt Switch Module. Image source: Joy-IT SensorKit KY-020 module documentation
KY-020 Raspberry Pi Wiring Diagram. Raspberry Pi Wiring Diagram for the KY-020 Tilt Switch Module. Image source: Joy-IT SensorKit KY-020 module documentation

What it is

A tilt switch is a simple orientation sensor. In this kit it is a ball-type switch with a metal ball inside.

How students use it

Students use it for shake/tilt detection, orientation alarms, countdown games, and simple movement-triggered inputs.

Pins and power

Two switch leads. The circuit opens or closes depending on angle.

Passive switch. Read it as a 3.3V-safe digital input with a pull-up or pull-down.

SunFounder explains that tilting lets the metal ball roll onto the contacts and complete the circuit; returning it away from the contacts opens the circuit.

Voltage and safety

Keep it on a Pico-safe 3.3V input circuit. Do not use it to switch high-current loads.

Treat it as a signal switch only. Power off before moving it on the breadboard.

Module internals

Metal ball, internal contacts, sealed switch body, and two leads.

Datasheet notes

SunFounder links an SW-520D tilt switch datasheet. Use the exact switch marking before relying on mechanical angle or current ratings.

Common libraries

No special library is needed. Use machine.Pin and debounce or sample over time.

Common mistakes

Expecting an exact angle threshold, ignoring contact bounce, mounting it in the wrong orientation, and leaving the GPIO input floating.