Products

News

Contact Us

Phone

Current Position > Products

Product Name: KEYES Magic cup light module , 2pcs with demo code

Magic Light Cup module is a module that can interact and ARDUINO,
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.
arduino 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);
}

Magic Light Cup module is a module that can interact and ARDUINO,
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.

arduino 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);
}


Operating Voltage: DC 3-5V

Second, characteristics:

1, single-channel signal output with indicator light;

2, when the module tilt or shake, the output low-level signals;

3, with mounting holes for easy fixed installation;

4, the output switch circuit board, which can be accessed microcontroller IO port directly.