I am trying to use a vibration sensor with my Raspberry Pi. The wiring looks like this:
3.3V -> VIBRATION SENSOR -> LED (Grounded) -> GPIO6
Whenever I touch the vibration sensor, the led goes on.
I wrote the following script:
from time import sleep import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(6, GPIO.IN) sleep(0.1) while True: result = GPIO.input(6) if result == 1: print("Vibrated")
The problem is that I am getting tons of vibration even when nothing touches the sensor (the LED is off).
What I am doing wrong here? I would expect the GPIO to report high only when a 3.3V current flows through the wire.