Current location::Home > Products

KY-027

  • Product description
  • Applications
  • Features
  • Pictures
  • Accessories
  • Download

The magic light cup contains two identical modules, a single module is composed of an LED light and a mercury switch.
The principle of dimming is to use two modules to change the principle of brightness as pwm. The Mercury switch provides a digital signal to trigger the PWM through programming, and we can see that the light of the two cups is full of the effect of dragging back and forth.
Test code:
int LedPinA = 5;
int LedPinB = 6;
int ButtonPinA = 7;
int ButtonPinB = 4;
int buttonStateA = 0;
int buttonStateB = 0;
int brightness = 0;
void setup()
pinMode (LedPinA, OUTPUT);
pinMode (LedPinB, OUTPUT);
pinMode (ButtonPinA, INPUT);
pinMode (ButtonPinB, INPUT);
void loop()
buttonStateA = digitalRead(ButtonPinA);
if (buttonStateA == HIGH && brightness!= 255)
Brightness++;
buttonStateB = digitalRead(ButtonPinB);
if (buttonStateB == HIGH && brightness!= 0)
Brightness-;
analogWrite(LedPinA, brightness); //
analogWrite(LedPinB, 255-brightness); //