Klopfsensor:

Anschlüsse PiAnschlüsse Sensor
GND
3,3V+
GPIO14S

Python

import RPi.GPIO as gpio
import time

sensor = 14
previous_state = 0

gpio.setmode(gpio.BCM)
gpio.setup(sensor, gpio.IN)

try:
  while True:
    if(gpio.input(sensor) == 0 ):
      print("bewegung")
except KeyboardInterrupt:
  gpio.cleanup()