0% found this document useful (0 votes)
13 views6 pages

Arduino RGB LED Color Simulation Guide

This document describes how to create a circuit with Arduino that uses an RGB LED to display different colors randomly. It explains the necessary components such as the Arduino board, an RGB LED, resistors, and wires. It also describes how to connect the circuit and program Arduino to control the RGB LED digitally and analogically using code in mBlock.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views6 pages

Arduino RGB LED Color Simulation Guide

This document describes how to create a circuit with Arduino that uses an RGB LED to display different colors randomly. It explains the necessary components such as the Arduino board, an RGB LED, resistors, and wires. It also describes how to connect the circuit and program Arduino to control the RGB LED digitally and analogically using code in mBlock.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Arduino: RGB LED

The objective of this exercise is to continue learning the basic functioning of the board.
Arduino and its interaction with the digital world.

The objective of this exercise is to create a simulation in the digital world (screen of
computer through S4A) and in the physical world (through electronic elements and
Arduino) of an element that shows a random color. In this case, we will use an LED.
RGB will allow us to display the entire color spectrum.

Necessary material

Name Image Description

Arduino Uno board (or any)


another version) with the firmware
Arduino board
necessary to be able to use S4A
One
(download firmware) loaded in the
plate.

Connection board or breadboard


Breadboard, what we will use in the assembly of
breadboard or electrical-electronic circuits for
plate of save and simplify the wiring.
connections To learn something more about the use
of this pulse devicehere

So far we have used several


LED combinations, but
1 LED diode always of a defined color.
RGB (cathode Usually the reds and yellows
common) they are the easiest to obtain,
but they can also be purchased at
shades of blue, green, and even white.
There are usually not great differences.
among them except for the color.

But sometimes it is interesting to have


from a pilot light that changes color
according to the conditions. For example,
we all identify green as
a signal of OK, while the red
indicates problems and the yellow…
well, something intermediate.

Put several diodes to do this


it is cumbersome and complicates the design,
so it would be good to have a
diode that we can indicate that
color we want to show. This is
unLED RGB (more information)
The 220-ohm resistor is used
to prevent the LEDs from receiving
too much intensity (due to its
3 resistors of
low internal resistance) and can
220 Ohms
function incorrectly or
overheat and stop being
operational.

Cables of
connections between
These cables allow us to connect
the components
in a simple way all the
the plate of
circuit elements.
tests and
Arduino

Electric circuit

In the previous articles(Project 1: Traffic Light Colors)we saw how to connect


correctly 3LED (red, green and yellow) to create a traffic light. Now we are going to use
a single RGB LED that will show us all the colors we desire from the color spectrum.

Digital behavior

If we have understood the circuit with 3 LEDs, it is also easy to understand this circuit since
we will work in digital mode, that is, we will only be able to impose the on/off value
to each of the components (R -> RED, G -> GREEN, B -> BLUE) so only
we will be able to obtain the following colors:
oRed: when the R component is on and the other two are off.
o Green: when the G component is on and the other two are off.
oBlue: when component B is on and the other two are off.
oYellow: when the R and G components are on and the B is off.
oPurple/pink: when the R and B components are on and the G is off.
oLight blue: when the G and B components are on and the R is off.

It should only be noted that since it is a common cathode RGB LED, the pin
the longer one must be connected to the negative of the board (Earth or GND) through a
resistance, while each of the other pins (see lower image) corresponding
each of the colors will be connected to the PWM pins that will allow us to control the
RGB LED both digitally (like in this example) and analogically (example
posterior). In our case, we will connect the red pin of the RGB (R) to the PWM pin 6, the pin
green from the RGB (G) to PWM pin 5 and the blue pin of the RGB (B) to PWM pin 3 after and how
show the image.

Analog behavior

If we want to work in analog mode, that is, if we want to control the tonalities between
the possible values of 0-255 of each of theRGB colors
[Link]

we must work in analog mode using the PWM pins of Arduino that will be useful for
generate analog outputs. In this way, giving specific values to each of the tones
we can make the RGB LED shine in any imaginable color shade that
they are shown in the following color scheme:

mBlock Code

mBlock code

As we already know, in order to use mBlock with our Arduino board, we must always...
update the board with firmware that allows interaction between mBlock and our
Arduino controller. For a detailed description of the connection steps, follow this link
[Link]
Once we have managed to get the mBlock environment to recognize our board, we must
fulfill our challenge by using programming in mBlock and generate a new file
that will fulfill the different functions of the program. As we will work digitally
And with the LED we will create 2 different programs that we will call 'RGBDigital.sb2'.
and 'RGBAnalogico.sb2' respectively. In these programs, we will change the colors of
LED every 5 seconds following the next sequence: in the first case (digital)
we will change RED (R) - GREEN (G) - BLUE (B) - YELLOW - PURPLE (PINK) -
LIGHT BLUE while in the second (analog) we will perform a similar sequence,
but with intermediate tones. In the following images, each one is shown with comments.
of the developments:

You might also like