Magic Cup Light Module (KY-027) [D020]
https://www.youtube.com/watch?v=yrBU-JRPk8M
*GitHub : https://github.com/rdiot/rdiot-d020.git
* Specs
Magic Light Cup modules are easy to Interactive Technology Division developed a can and ARDUINO interactive modules, PWM dimming principle is to use the principle of two modules brightness changes. Mercury switches provide a digital signal that triggers the PWM regulator, through the program design, We can see the light like two cups filled with the effect of shuffling back and forth.
* Contents
- Connect
G ----- GND
+ ----- X
S ----- D10
L ----- D11
- Key Code
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4); // LCD2004
int pinLed = 11;
int pinInput = 10;
int stateA = 0;
int brightness = 0;
int oldBrightness = 0;
void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.print("start LCD2004");
pinMode(pinLed, OUTPUT);
pinMode(pinInput, INPUT); delay(1000);
digitalWrite(pinInput, HIGH);
lcd.clear();
}
void loop()
{
lcd.setCursor(0,0);
lcd.print("D020:Magic Cup Light");
stateA = digitalRead(pinInput);
if (stateA == HIGH && brightness < 255)
brightness++;
if (stateA == LOW && brightness >0)
brightness--;
if (oldBrightness != brightness)
{
lcd.setCursor(0,1);
lcd.print("brightness=" + (String)brightness + " ");
}
oldBrightness = brightness;
analogWrite(pinLed, brightness);
delay(10);
}
'3) Actuator > LED' 카테고리의 다른 글
Arrow Indicator 14 SMD LED Blue [D077] (0) | 2016.09.19 |
---|---|
Bargraph Segment LED Module (SHB10R) [D024] (0) | 2016.09.19 |
RGB LED Module SMD (KY-009) [D008] (0) | 2016.09.18 |
RGB LED Module DIP (KY-016) [D007] (0) | 2016.09.18 |
RGB LED (BL-L515) [D006] (0) | 2016.09.18 |