• Part: KY-020
  • Description: Tilt switch module
  • Manufacturer: Joy-IT
  • Size: 354.33 KB
Download KY-020 Datasheet PDF
Joy-IT
KY-020
KY-020 is Tilt switch module manufactured by Joy-IT.
- Part of the KY-020-Joy comparator family.
KY-020 Tilt switch module KY-020 Tilt switch module Contents 1 Pircture ................................................................................................................................................................ 1 2 Technical data / Short description ....................................................................................................................... 1 3 Pinout ................................................................................................................................................................... 2 4 Code example Arduino ......................................................................................................................................... 2 5 Code example Raspberry Pi ................................................................................................................................. 3 Pircture Technical data / Short description Depending on the angle, a switch connects the circuit. Export: 16.06.2017 Copyright by Joy-IT - Published under CC BY-NC-SA 3.0 Page 83 of 214 KY-020 Tilt switch module Pinout Code example Arduino This example will light up a LED after a sensor detected a signal. the modules KY-011, KY-016 or KY-029 could be used as LED too for example. 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 will be 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 84 of 214 KY-020 Tilt switch...