The LED is switched on or off in the event of vibration. The trigger signal, which controls the LED, is additionally forwarded to the signal output.


Depending on the input voltage, series resistors are required.

Series resistor (3.3 V) [Red] 120 Ω
Series resistor (5 V) [Red] 220 Ω

Pin assignment

Code example Arduino

Pin assignment Arduino

Arduino Sensor
Pin 10 signal
5 V +V
Ground GND
Arduino Sensor
Pin 13 LED +
Ground LED -
int Led = 13 ;// Declaration of the LED output pin
int Sensor = 10 ;// Declaration of the sensor input pin
int val; // Temporary variable
void setup ()
  pinMode (Led, OUTPUT) ; // Initialize output pin
  pinMode (Sensor, INPUT) ; // Initialize sensor pin
  digitalWrite(Sensor, HIGH) ; // Activate internal pull-up resistor
void loop ()
  val = digitalRead (Sensor) ; // The current signal at the sensor is read out
  if (val == HIGH) // If a signal could be detected, the LED is switched on.
    digitalWrite (Led, LOW);
    digitalWrite (Led, HIGH);

Example program download

Code example Raspberry Pi

Pin assignment Raspberry Pi

Raspberry Pi Sensor
GPIO 23 [Pin 16] Signal
5 V +V
Ground GND
Raspberry Pi Sensor
GPIO 24 [Pin 18] LED +
Ground LED -

Programming example in the Python programming language.

# Required modules are imported and set up
import RPi.GPIO as GPIO
import time
# Here the two pins are declared, to which the sensor and the LED are connected,
LED_PIN = 24
Sensor_PIN = 23
GPIO.setup(Sensor_PIN, GPIO.IN)
print ("Sensor test [press CTRL+C to end test]")
# This outputFunction will be executed when a signal is detected
def outputFunction(null):
        GPIO.output(LED_PIN, True)
# When a signal is detected the output function is executed
GPIO.add_event_detect(Sensor_PIN, GPIO.FALLING, callback=outputFunction, bouncetime=10) 
# main program loop
    while True:
        #output is reset if the tilt switch is tilted to the other side again
        if GPIO.input(Sensor_PIN):
# Clean up after the program is finished
except KeyboardInterrupt:

Download sample program

To start with the command:

sudo python3

Code example Micro:Bit

Pinout Micro:Bit:

Micro:Bit Sensor
Pin 2 LED
Pin 1 Signal
3 V +V
Ground GND

Sample program download