Measuring the strength of vibration (length of the pulse) and raw data from a sensor breakout is provided below in C:
http://www.theorycircuit.com/sw-420-vib ... interface/
How can the same be done in python?
supra wrote: ↑Thu Dec 14, 2017 1:41 pmI do not test this. Because I don't have vibration.
Code: Select all
import RPi.GPIO as GPIO from time import sleep GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) vibr_pin = 8 LED_Pin = 10 GPIO.setup(channel, GPIO.IN) GPIO.setup(channel, GPIO.OUT) while True: val = 0 val = input(vibr_pin) if(val==1): GPIO.output(LED_Pin, GPIO.HIGH) sleep(1000) GPIO.output(LED_Pin, GPIO.LOW) sleep(1000) else: GPIO.output(LED_Pin, GPIO.LOW) GPIO.cleanup()