Today, we have the module called RGB LED SMD module. The structure of the module has a surface-mount device (that's why it is called SMD). It is an electronic device whose components are mounted on the surface of PCB based on the surface-mount technology (SMT) instead of through-hole technology (THT).
In the previous article, we discussed about the RGB LED module, which is based on through-hole technology (THT) and has built-in resistors. It is noticeable on the image below that the SMD module has a small in size and no built-in resistors included in the module.
Note: Do not use this module directly to arduino without the limiting resistors attached to each pin, or else it would burnt out and you may not use it any longer. You should get 3 items of 220 ohms (or less), and attached each of these in series to R, G B pin in order to use this module.
The RGB LED SMD module has 4 pins, namely, the common cathode ( - or GND) pin, green pin, red pin and blue pin respectively (see the image above).
Let's test this module. The code below will display every second for red, followed by green and then blue color.
Red, Green and Blue color display
If you want to display the LED beyond 3 colors, then we are going to use the pulse-width modulation (PWM) pins ( example: 10, 11, 12 pins). We will use the analogWrite() function instead of digitalWrite() function to use this PWM. To achieve the different colors, it uses the different number values of each color, ranging from 0 to 255.
See the code below for diferent colors (combination of RGB colors)
Upload the code and check the result. You will see different colors beyond red, green and blue colors. Enjoy!