close
videotogif_2018.05.31_21.33.46[1]

Colorful Light

We’ve blinked an LED and controlled eight in sequence now it’s time to control color. Using an RGB LED (actual 3 LEDs in a single housing) we can generate any color our heart desires. We do this through color mixing, what’s required is delving back to your elementary art days of playing with colored cellophane to produce different colors (if you can’t remember that far back don’t worry here’s a color wheel to help you out).

Hardware Used:

  • 1 – RGB LED
  • 3 – 100 ohms
  • 1 – Arduino UNO

You can buy all this Hardware at Createlabz.

Software Used:

Arduino IDE

Set up the Hardware:

Code:

 

Code Breakdown:

pinouts for the RGB LED.

The const keyword stands for constant. It is a variable qualifier that modifies the behavior of the variable, making a variable “read-only“. This means that the variable can be used just as any other variable of its type, but its value cannot be changed.

that’s a loop that says, okay, for every time that i is smaller than 3, I’m going to do whatever is in the code block. Whenever i reaches 3, It will stop.

Note : Some codes were explained in the previous activity go and check it out!

Try More!!!

More Colors:

I imagine you are less than impressed by the cyan glowing LED before you. To display different color change the color in the code to one of the others.

Display a Random Color:

Of course we can do more than display a constant color to see how we cycle through random colors change the loop() code to.

 

 

Tags : arduinoArduino KitBasicColorcolor ledcolorfulLedRGBStarter Kit

Leave a Response