KY-020 TILT SWITCH MODULE
$16.2
$31.43
The KY-020 Tilt Switch Sensor module is a switch that reacts to movement. It closes the circuit when it’s tilted to the side as long as it is moved with enough force and degree of inclination to activate the ball switch inside.Compatible with Arduino, Raspberry Pi, ESP32 and other microcontrollers.KY-020 SPECIFICATIONSThis module consists of a 10kΩ resistor, a metallic ball switch with bidirectional conduction that will open/close the circuit when tilted, and 3 male header pins. This module does not measure tilt angle.Operating Voltage3.3V ~ 5VOutput TypeDigitalCONNECTION DIAGRAMConnect the module’s Power line (middle) and ground (-) to 5 and GND respectively.Connect signal (S) to pin 2 on the Arduino.KY-020ArduinoS2middle 5V–GNDKY-020 ARDUINO CODEThe following sketch will turn on the LED on pin 13 of the Arduino when the module inclination degree changes. Tilt the module to turn the LED on/off.Arduino int tiltPin = 2; // pin number for tilt switch signal int ledPin = 13; // pin number of LED int tiltState = 0; // variable for reading the tilt switch status void setup() { pinMode(ledPin, OUTPUT); // set the LED pin as output pinMode(tiltPin, INPUT); // set the tilt switch pin as input } void loop(){ // get the tilt switch state tiltState = digitalRead(tiltPin); // check if tilt switch is tilted. if (tiltState == HIGH) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } }123456789101112131415161718192021int tiltPin = 2; // pin number for tilt switch signal int ledPin = 13; // pin number of LED int tiltState = 0; // variable for reading the tilt switch status void setup() { pinMode(ledPin, OUTPUT); // set the LED pin as output pinMode(tiltPin, INPUT); // set the tilt switch pin as input} void loop(){ // get the tilt switch state tiltState = digitalRead(tiltPin); // check if tilt switch is tilted. if (tiltState == HIGH) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); }} DOWNLOADSFritzing Part: KY-020 Tilt Switch Module.Fritzing Official Site.
Motion