KY-027 Magic light cup module
KY-027 Magic light cup module
Contents 1 Picture . 1 2 Technical data / Short description . . . . 1 3 Pinout . . . 2 4 Code example Arduino . . 2 5 Code example Raspberry Pi . . . . 3
Picture
Technical data / Short description
The LED will be switched on and off by vibration. The signal will be send to the output if the LED is on. You need pre-resistors for some voltages.
Pre-resistor: Rf (3,3V) [Red]= 120Ω [used with ARM CPU-Core based microcontroller like Raspberry-Pi]
Rf (5V) [Red] = 220Ω
Export: 16. 06. 2017
Copyright by Joy-IT - Published under CC BY-NC-SA 3. 0
Page 125 of 214
KY-027 Magic light cup module [used with Atmel Atmega based microcontroller like Arduino]
Pinout
Code example Arduino
int Led = 13 ;// Declaration of the LED-output pin int Sensor = 10; // Declaration of the sensor input pin int val; // Temporary variable void setup () {
pinMode (Led, OUTPUT) ; // Initialization output pin pinMode (Sensor, INPUT) ; // Initialization sensor pin digitalWrite(Sensor, HIGH); // Activating of the internal pull-up resistor } void loop () { val = digitalRead (Sensor) ; // The current signal from the sensor will be read if (val == HIGH) // If a signal will be detected, the LED will light up. {
digitalWrite (Led, LOW); } else {
digitalWrite (Led, HIGH); } }...