Lesson 4 RGB LED. Overview. Component Required:

Similar documents
Arduino Lesson 3. RGB LEDs

Module 4: Traffic Signal Design Lesson 1: Traffic Signal (Arduino) Control System Laboratory Exercise Grade 6-8

Ginger Bread House

R,G,B LEDs. Three PWM outputs and three primary colors. Just screams to be made, doesn t it? 220 (red,red,brown) or 330 (orange,orange,brown)

Model Railway Animation: Part 1, LEDs - Expanded By David King

Experiment 0: Hello, micro:bit!

EP486 Microcontroller Applications

Objectives: Learn how LED displays work Be able to output your name on the display

Preface. About SunFounder. About Super Kit. Free Support

1. Arduino Board and Breadboard set up from Project 2 (8 LED lights) 2. Piezo Speaker

ENGR 40M Project 3b: Programming the LED cube

Preface. If you have any TECHNICAL questions, add a topic under FORUM section on our website and we'll reply as soon as possible.

Character LCDs. Created by lady ada. Last updated on :47:43 AM UTC

CT-DMX-300 LED Controller

The Infinity Portal Craig A. Lindley 03/16/2011

Introduction. The Clock Hardware. A Unique LED Clock Article by Craig A. Lindley

Lecture (04) Arduino Microcontroller Programming and interfacing. By: Dr. Ahmed ElShafee

Computer Architecture and Organization. Electronic Keyboard

Digital 1 Final Project Sequential Digital System - Slot Machine

Microcontrollers and Interfacing week 7 exercises

The Micropython Microcontroller

Laboratory 11. Required Components: Objectives. Introduction. Digital Displays and Logic (modified from lab text by Alciatore)

Smart Interface Components. Sketching in Hardware 2 24 June 2007 Tod E. Kurt

Dynamic Animation Cube Group 1 Joseph Clark Michael Alberts Isaiah Walker Arnold Li

LT-300 LED Controller

Bill of Materials: 7-Segment LED Die with Arduino PART NO

16 Universe LED Matrix Panels Instructions

Arduino LED Matrix Control. Controlling lots of LEDs

Touch Panel RGB LED Controller Part No. touch-panel-rgb

DMC550 Technical Reference

MAKEVMP502 BASIC LEARNING KIT FOR RASPBERRY PI USER MANUAL

Light Emitting Diodes (LEDs)

Monolithic CMOS Power Supply for OLED Display Driver / Controller IC

StickIt! VGA Manual. How to install and use your new StickIt! VGA module

Lesson Sequence: S4A (Scratch for Arduino)

Assignment #3: Piezo Cake

This module senses temperature and humidity. Output: Temperature and humidity display on serial monitor.

COMP2611: Computer Organization Building Sequential Logics with Logisim

Laboratory 8. Digital Circuits - Counter and LED Display

Measure the value of water flow using water flow sensor and DC water pump 12 V interfacing with Arduino uno

MAKE AN RGB CONTROL KNOB.

Chapter 4: One-Shots, Counters, and Clocks

Solutions to Embedded System Design Challenges Part II

VGA Port. Chapter 5. Pin 5 Pin 10. Pin 1. Pin 6. Pin 11. Pin 15. DB15 VGA Connector (front view) DB15 Connector. Red (R12) Green (T12) Blue (R11)

Experiment (6) 2- to 4 Decoder. Figure 8.1 Block Diagram of 2-to-4 Decoder 0 X X

Product Specification

W0EB/W2CTX DSP Audio Filter Operating Manual V1.12

Design and Implementation of Timer, GPIO, and 7-segment Peripherals

BLINKIN LED DRIVER USER'S MANUAL. REV UM-0 Copyright 2018 REV Robotics, LLC 1

SparkFun Inventor's Kit for micro:bit Experiment Guide

The UK sequence is shown below. The duration of each phase can be easily adjusted during the programming to suit.

Rfid Based Attendance System

TV Synchronism Generation with PIC Microcontroller

Basic LabVIEW Programming Amit J Nimunkar, Sara Karle, Michele Lorenz, Emily Maslonkowski

Building the ChronoDot Calendar Reminder

Design and Implementation of an AHB VGA Peripheral

LCD MODULE SPECIFICATION

Device: LDP This document Version: 1.1. Date: July Description: 64x16 1R1G LED Display Panel

Studio DMX Decoders. Part numbers: DMX , DMX , DMX

PHYS 3322 Modern Laboratory Methods I Digital Devices

Microcontrollers. Outline. Class 4: Timer/Counters. March 28, Timer/Counter Introduction. Timers as a Timebase.

Lab Using The Multimeter And The Trainer

10 Zone RGB-W LED Controller

Music-Visualization and Motion-Controlled LED Cube

LEVEL CROSSING MODULE FOR LED SIGNALS LCS2

Design of a Binary Number Lock (using schematic entry method) 1. Synopsis: 2. Description of the Circuit:

CSCB58 - Lab 4. Prelab /3 Part I (in-lab) /1 Part II (in-lab) /1 Part III (in-lab) /2 TOTAL /8

VGA to PAL and NTSC converter

successive approximation register (SAR) Q digital estimate

Lab #6: Combinational Circuits Design

SHOWLINE SL NITRO 510 LED STROBE LUMINAIRE SPECIFICATIONS.

Data Acquisition Using LabVIEW

Doc: page 1 of 5

uresearch GRAVITECH.US GRAVITECH GROUP Copyright 2007 MicroResearch GRAVITECH GROUP

WiFi Time Provider v1 for Arduino Nixie Clock Operating Instructions & Construction Manual

Alice EduPad Board. User s Guide Version /11/2017

LT A LED RGB Controller. User s Manual

Theory and Practice of Tangible User Interfaces. Thursday Week 3: Analog Input. week. Sensor 1: Potentiometers. Analog input

SHOWLINE SL NITRO 510C LED STROBE LUMINAIRE SPECIFICATIONS.

4.3 8 bit TFT Digital Driver Board Specification

Laboratory 9 Digital Circuits: Flip Flops, One-Shot, Shift Register, Ripple Counter

4.3inch 480x272 Touch LCD (B) User Manual

Bill of Materials: Super Simple Water Level Control PART NO

Description Diagram Page

L14 - Video. L14: Spring 2005 Introductory Digital Systems Laboratory

Palestine Technical College. Engineering Professions Department. EEE Digital Logic Fundamentals. Experiment 2.

Circuit Playground Express (& other ATSAMD21 Boards) DAC Hacks

Lab 7: Soldering - Traffic Light Controller ReadMeFirst

DOGM GRAPHIC SERIES 132x32 DOTS

One Shot, Two Shot, Red Shot, Blue Shot. Build Instructions

9/23/2014. Andrew Costin, Tom Syster, Ryan Cramer Advisor: Professor Hack Instructor: Professor Lin May 5 th, 2014

Part (A) Controlling 7-Segment Displays with Pushbuttons. Part (B) Controlling 7-Segment Displays with the PIC

Chapter 3: Sequential Logic Systems

ECE Lab 5. MSI Circuits - Four-Bit Adder/Subtractor with Decimal Output

7 SEGMENT LED DISPLAY KIT

CPE 200L LABORATORY 3: SEQUENTIAL LOGIC CIRCUITS UNIVERSITY OF NEVADA, LAS VEGAS GOALS: BACKGROUND: SR FLIP-FLOP/LATCH

Using different reference quantities in ArtemiS SUITE

Mal-2 assembly guide v1.0

Digital (5hz to 500 Khz) Frequency-Meter

QUIZ BUZZER KIT TEACHING RESOURCES. Version 2.0 WHO ANSWERED FIRST? FIND OUT WITH THIS

Transcription:

Lesson 4 RGB LED Overview RGB LEDs are a fun and easy way to add some color to your projects. Since they are like 3 regular LEDs in one, how to use and connect them is not much different. They come mostly in 2 versions: Common Anode or Common Cathode. Common Anode uses 5V on the common pin, while Common Cathode connects to ground. As with any LED, we need to connect some resistors inline (3 total) so we can limit the current being drawn. In our sketch, we will start with the LED in the Red color state, then fade to Green, then fade to Blue and finally back to the Red color. By doing this we will cycle through most of the color that can be achieved. Component Required: (1) x Elegoo Uno R3 (1) x 830 Tie Points Breadboard (4) x M-M wires (Male to Male jumper wires) (1) x RGB LED (3) x 220 ohm resistors 44 / 83

Component Introduction RGB: At first glance, RGB (Red, Green and Blue) LEDs look just like regular LEDs. However, inside the usual LED package, there are actually three LEDs, one red, one green and yes, one blue. By controlling the brightness of each of the individual LEDs you can mix pretty much any color you want. We mix colors the same way you would mix paint on a palette - by adjusting the brightness of each of the three LEDs. The hard way to do this would be to use different value resistors (or variable resistors) as we did with in Lesson 2, but that's a lot of work! Fortunately for us, UNO R3 board has an analogwrite function that you can use with pins marked with a ~ to output a variable amount of power to the appropriate LEDs. The RGB LED has four leads. There is one lead going to the positive connection of each of the single LEDs within the package and a single lead that is connected to all three negative sides of the LEDs. 45 / 83

Here on the photographs you can see 4 electrode LED. Every separate pin for Green or Blue or Red color is called Anode. You will always connect + to it. Cathode goes to - (ground). If you connect it other way round the LED will not light. The common negative connection of the LED package is the second pin from the flat side. It is also the longest of the four leads and will be connected to the ground. Each LED inside the package requires its own 220Ω resistor to prevent too much current flowing through it. The three positive leads of the LEDs (one red, one green and one blue) are connected to UNO output pins using these resistors. 46 / 83

COLOR: The reason that you can mix any color you like by varying the quantities of red, green and blue light is that your eye has three types of light receptor in it (red, green and blue). Your eye and brain process the amounts of red, green and blue and convert it into a color of the spectrum. In a way, by using the three LEDs, we are playing a trick on the eye. This same idea is used in TVs, where the LCD has red, green and blue color dots next to each other making up each pixel. If we set the brightness of all three LEDs to be the same, then the overall color of the light will be white. If we turn off the blue LED, so that just the red and green LEDs are the same brightness, then the light will appear yellow. We can control the brightness of each of the red, green and blue parts of the LED separately, making it possible to mix any color we like. Black is not so much a color as an absence of light. Therefore, the closest we can come to black with our LED is to turn off all three colors. 47 / 83

Theory (PWM) Pulse Width Modulation (PWM) is a technique for controlling power. We also use it here to control the brightness of each of the LEDs. The diagram below shows the signal from one of the PWM pins on the UNO. Roughly every 1/500 of a second, the PWM output will produce a pulse. The length of this pulse is controlled by the 'analogwrite' function. So 'analogwrite(0)' will not produce any pulse at all and 'analogwrite(255)' will produce a pulse that lasts all the way until the next pulse is due, so that the output is actually on all the time. If we specify a value in the analogwrite that is somewhere in between 0 and 255, then we will produce a pulse. If the output pulse is only high for 5% of the time, then whatever we are driving will only receive 5% of full power. If, however, the output is at 5V for 90% of the time, then the load will get 90% of the power delivered to it. We cannot see the LEDs turning on and off at that speed, so to us, it just looks like the brightness is changing. 48 / 83

Connection Schematic 49 / 83

Wiring diagram 50 / 83

Code After wiring, please open the program in the code folder- Lesson 4 RGB LED, and click UPLOAD to upload the program. See Lesson 2 for details about program uploading if there are any errors. Our code will use FOR loops to cycle through the colors. The first FOR loop will go from RED to GREEN. The second FOR loop will go from GREEN to BLUE. The last FOR loop will go from BLUE to RED. Try the sketch out and then we will dissect it in some detail... The sketch starts by specifying which pins are going to be used for each of the colors: // Define Pins #define BLUE 3 #define GREEN 5 #define RED 6 The next step is to write the 'setup' function. As we have learnt in earlier lessons, the setup function runs just once after the Arduino has reset. In this case, all it has to do is define the three pins we are using as being outputs. void setup() { pinmode(red, OUTPUT); pinmode(green, OUTPUT); pinmode(blue, OUTPUT); digitalwrite(red, HIGH); digitalwrite(green, LOW); digitalwrite(blue, LOW); } Before we take a look at the 'loop' function, let s look at the last function in the sketch. The define variables redvalue = 255; // choose a value between 1 and 255 to change the color. greenvalue = 0; 51 / 83

bluevalue = 0; This function takes three arguments, one for the brightness of the red, green and blue LEDs. In each case the number will be in the range 0 to 255, where 0 means off and 255 means maximum brightness. The function then calls 'analogwrite' to set the brightness of each LED. If you look at the 'loop' function you can see that we are setting the amount of red, green and blue light that we want to display and then pausing for a second before moving on to the next color. #define delaytime 10 // fading time between colors Delay(delayTime); Try adding a few colors of your own to the sketch and watch the effect on your LED. Example picture 52 / 83