Magic light cup modules

Magic light cup modules
Euro 1.50 *Prijzen zijn inclusief btw
ArtikelcodeARD154
Magic light cup module, 2 stuks. Geschikt voor Arduino maar ook voor andere microcontrollers.

Op voorraad / on stock
Magic light cup module, 2 stuks. Geschikt voor Arduino maar ook voor andere microcontrollers.

Example 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);  //  A will turn off gradually

     analogWrite(LedPinB, 255 - brightness);  // B will turn on gradually

     delay(25);

}