Your position: Home / Sensors

Free shipping !Keyestudio Magic light cup module compatible with Arduino

KS0030
Price:
Wholesale:
5+
$1.89
    Please select the information you wantX
Quantity:
-
+
(990 available)
Shipping Cost:
to
Estimated Delivery Time:
Please select the country you want to ship from
  • Description
  • Reviews(92)
1 2 2R 3 4 5
Introduction
 
Magic light cup module can interact with Aduino. It works by the principle of PWM dimming to change the brightness of two modules. The mercury switch provides digital signal and triggers PWM dimming. Then by combining with programs, we can achieve the effect of two cups full of light flipping back and forth.
 

Sample 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, 2

55 - brightness);

delay(25);

}

See product video: https://youtu.be/9bqY2XuyyRg

 

Average rating: 4.0 based on 92 reviews
Share your thoughts with other customers
Write a review
Product reviews can be carried out after the member login, please click here to login