• Part: KY-031
  • Description: Knock-sensor module
  • Manufacturer: Joy-IT
  • Size: 351.64 KB
Download KY-031 Datasheet PDF
Joy-IT
KY-031
KY-031 is Knock-sensor module manufactured by Joy-IT.
- Part of the KY-031-Joy comparator family.
description 1 3 Pinout 2 4 Code example Arduino 2 5 Code example Raspberry Pi 3 Picture Technical data / Short description On knocks or vibrations, the contact of the two input pins are connected. Export: 16.06.2017 Copyright by Joy-IT - Published under CC BY-NC-SA 3.0 Page 140 of 214 KY-031 Knock-sensor module Pinout Code example Arduino This example will light up a LED after the sensor detected a knock or vibration. The modules KY-011, KY-016 or KY-029 can be used as an 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 () { pin Mode (Led, OUTPUT) ; // Initialization output pin pin Mode (Sensor, INPUT) ; // Initialization sensor pin } void loop () { val = digital Read (Sensor) ; // The current signal at the sensor will be read if (val == HIGH) // If a signal was detected , the LED will light up { digital Write (Led, LOW); } else { digital Write (Led, HIGH); } } Connections Arduino: LED + LED Sensor signal Sensor +V = [Pin 13] = [Pin GND] = [Pin 10] = [Pin 5V] Export: 16.06.2017 Copyright by Joy-IT - Published under CC BY-NC-SA 3.0 Page 141 of 214 KY-031 Knock-sensor module Sensor - = [Pin GND] Example program download Sensor Test Arduino Code example Raspberry Pi # Needed modules will be imported and configured import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) #GPTIh Oe_Pi In Npu=t2p4in of the sensor...