fbpx
Arduino Lesson 15: RGB Module
Arduino Lesson 15

RGB Module

Change colors of RGB LED as required

Components Required

Buy
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 color. R- Red G- Green B- Blue

Learning outcomes:

  • Using a 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 in human perception of colors

Methodology

For this demonstration, you have to install 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 connect the RGB module to the Magicbit, connect it to your pc and upload 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 single RGB LED as your requirement (like this example). ‘LED.begin & LED.show’ are functions of Adafruit NeoPixel library for display the color on RGB led. ‘LED.setPixelColor’ is use to color led brightness values. (Eg:- 255 – maximum brightness & 0 – lowest brightness)

Related Posts
Leave a Reply

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