X
  • Your position
  • Sign In or Join Free
Your position: Home / Sensors

Free shipping !Keyestudio Magic light cup module compatible with Arduino

KS0030
Wholesale:
5+
$1.89
    Please select the information you wantX
Quantity:
-
+
(989 available)
Shipping Cost:
to
Estimated Delivery Time:
Please select the country you want to ship from
  • Description
  • Reviews
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:
Share your thoughts with other customers
Write a review
Product reviews can be carried out after the member login, please click here to login
Download
Kit for Arduino
Robot for Arduino
Raspberry Pi
Micro:Bit
Overseas Clearance Sale
Ship to EU
Ship to US
Ship to CA
New Arrivals
Main products
Controller board
Expansion board
Learning kit
Robot KIT
Easy-plug RJ11 series
Easy-plug Learning Kit
Easy-plug Sensor
Links:autopartsUPS