• +965 51122049
Magic light cup module

Magic light cup module

KWD1.250KWD1.250
0%Off

Magic light cup module


 

 


Share:

Magic Light Cup modules are easy to Interactive Technology Division developed a can and ARDUINO interactive modules, PWM dimming principle is to use the principle of two modules brightness changes. Mercury switches provide a digital signal that triggers the PWM regulator, through the program design, We can see the light like two cups filled with the effect of shuffling back and forth.

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 few Guan Yuan (ii) ? 
	
	
  analogWrite (
	
	LedPinB,
	
	 255
	
	 -
	
	 brightness)
	
	;
	
	// B Yuan (ii) a few Bang ?
	
	
  delay (
	
	25
	
	)
	
	;
	
	
}
	
	

Note: This experiment requires two modules simultaneously.


Add your review

Your email address will not be published. Required fields are marked *

Please login to write review!

Upload photos

Looks like there are no reviews yet.

Related Products