fbpx
Arduino Lesson 15: RGB Module
Arduino Lesson 15

RGB Module

Change colors of RGB LED as required

Components Required

Magicbit
Buy
RGB Module
Buy

Introduction

An RGB LED has 4 pins, one for each color (Red, Green, Blue) and a common cathode. It has three different color-emitting diodes that can be combined to create all sorts of colors. R- Red G- Green B- Blue.

Learning outcomes:

  • Using an RGB led and changing its color as the required

Theory

The RGB color model is an additive color model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additive primary colors, red, green, and blue. The main purpose of the RGB color model is for the sensing, representation, and display of images in electronic systems, such as televisions and computers, though it has also been used in conventional photography. Before the electronic age, the RGB color model already had a solid theory behind it, based on human perception of colors.

Methodology

For this demonstration, you have to install the Adafruit NeoPixel library. For more details, click here. As usually connect the RGB module to your Magicbit, for this, we take data pin as pin 32. After connecting the RGB module to the Magicbit, connect it to your pc and upload the following code.

Code

 

#include <Adafruit_NeoPixel.h>
#define LED_PIN  32
#define LED_COUNT 1
Adafruit_NeoPixel LED(1,32, NEO_RGB + NEO_KHZ800);

void setup() {
  LED.begin();
  LED.show();
}

void loop() {
  LED.setPixelColor(0, 255, 0, 255); // you can change these arguments and make your own designs using those commands. Follow the link in our documentary for more details.
  LED.show();
}

Explanation

Adafruit NeoPixel library is for LED strips. However, it can be used for a single RGB LED as your requirement (like this example). ‘LED.begin & LED.show’ are functions of the Adafruit NeoPixel library to display the color on RGB LED. ‘LED.setPixelColor’ is used to color-led brightness values. (Ex:- 255 — maximum brightness & 0 — the lowest brightness)

Related Posts
Leave a Reply