Magic Light Cup Module (KY-027)

Mercury switches provide a digital signal that triggers the PWM , through the program design, we can then see the light like two cups filled with the effect of shuffling back and forth.

 

dimming principle is to use the principle of two modules brightness changes for pwm.

   Mercury switches provide a digital signal that triggers the PWM , through the program design,

   We can see the light like two cups filled with the effect of shuffling 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); //

   delay(25);

   }

[None Specified]

  • N/A

More from this Category

650nm Red Laser Transmitter Module

650nm Red Laser Transmitter Module

R 28.00 View
Mini 5V Traffic Light LED Display Module

Mini 5V Traffic Light LED Display Module

R 16.80 View
Ambient Light Sensor Module (TEMT6000)

Ambient Light Sensor Module (TEMT6000)

R 56.80 View
Laser Receiver Module

Laser Receiver Module

R 44.80 View
4X4X4 Blue LED 3D Matrix Light Cube DIY Arduino Shield Kit

4X4X4 Blue LED 3D Matrix Light Cube DIY Arduino Shield Kit

R 252.00 View
Infrared (IR) Transmitter Module

Infrared (IR) Transmitter Module

R 28.00 View
Out of Stock
WS2812B RGB 5050 LED Module

WS2812B RGB 5050 LED Module

R 16.80 View
KY-034 Automatic 7 Color Colour Flashing LED Module (Arduino)

KY-034 Automatic 7 Color Colour Flashing LED Module (Arduino)

R 6.51 View
Ambient Light Sensitivity Sensor Module (Temt6000)

Ambient Light Sensitivity Sensor Module (Temt6000)

R 44.80 View
WS2811/WS2812 RGB LED Module

WS2811/WS2812 RGB LED Module

R 22.40 View