Book Image

Arduino Development Cookbook

By : Cornel M Amariei
Book Image

Arduino Development Cookbook

By: Cornel M Amariei

Overview of this book

Table of Contents (16 chapters)
Arduino Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

RGB LED


We can get LEDs in a variety of colors these days, but what about an LED that can change color? We all know that a combination of Red, Green, and Blue (RGB) can give us any color. Using the Arduino PWM functionality, we will see how we can obtain 16 million color combinations with an RGB LED.

RGB LED stands for Red Green Blue LED. Inside such an LED we can find one red, one green, and one blue LED, mounted together.

Getting ready

The following are the ingredients needed for this recipe:

  • An Arduino board connected to the computer via USB

  • A breadboard and jumper wires

  • An RGB LED

  • Three equal resistors between 220–1,000 ohm

How to do it…

Follow these steps in order to connect an RGB LED to an Arduino board:

  1. Mount the RGB LED on the breadboard.

  2. We need to identify which pin represents which color and which pin is the common one. The following graphic explains just that:

  3. Connect 5V to the common anode (+) of the RGB LED. This is the longest of the four pins.

  4. Connect each smaller cathode (-) pin to...