RGB LED

R – Red, G – Green, B – Blue, basic display component to display color. We call this as one pixel for all display unit, such as monitor, TV and smart phone. It contains three inputs for red, green and blue, as well as a common ground(1). When we apply ‘analog’ voltage(2) to each corresponding pin, it will display the corresponding scale of the color. For Arduino, it can provide 0-255 scale of ‘analog’ voltage to the pin, i.e. we can get 256 different color scales of red, green or blue. If we put them together, it will give 256x256x256 = 16,777,216 colors!

(1) Do you know common anode and common cathode? see our separated post.

(2) Arduino analog output is generated by using PMW, check here to learn more.

void loop() {
  
  analogWrite (red, 255);
  analogWrite (green, 0);
  analogWrite (blue, 0);
  delay(1000);

  analogWrite (red, 0);
  analogWrite (green, 255);
  analogWrite (blue, 0);
  delay(1000);

  analogWrite (red, 0);
  analogWrite (green, 0);
  analogWrite (blue, 255);
  delay(1000);

  analogWrite (red, 0);
  analogWrite (green, 0);
  analogWrite (blue, 0);
  delay(1000);

  analogWrite (red, 255);
  analogWrite (green, 255);
  analogWrite (blue, 255);
  delay(1000);

  analogWrite (red, 232);
  analogWrite (green,97);
  analogWrite (blue, 0);
  delay(1000);

  analogWrite (red, 255);
  analogWrite (green,0);
  analogWrite (blue, 255);
  delay(1000);
}
BlackWhiteRedGreenBlueOrangePurple
R025525500232255
G025502550970
B0255002550255
Find your own color code here..

Since we need to provide ‘analog’ voltage to the RGB LED, we must be using port with ‘analog’ output support that you can see ‘~’ next to the port number, so that you can write 0 – 255 to the port to control color scale to generate different color and achieve different colors combination. Refer to above table for examples of color combination (we call this color code) or the link to a color code web site. All the color is the combination of RGB in term of hexadecimal number, e.g. #FF is 255, color code of red is #FF0000, color code of Orange is #E86100 where #E8 = 232, #61 = 97, #00 = 0.

What is pixel?

HD? 2K? 4K and 8K? When we talk about the monitor or TV, it’s quality is always related to the screen resolution, the higher resolution, more pixels, higher density, the better of the screen quality. For a 8K TV, it contains more than 33million tiny and very high quality RGB LED!!! That’s not easy to produce with good yield, that’s why it is very expensive!!!

XYTotal Pixels
Full HD192010802,073,600
2K256014403,686,400
4K384021608,294,400
8K7680432033,177,600
For a 8K TV, it contains 33million RGB Led!!

One thought on “RGB LED

Leave a Reply

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