Arduino RGB LED Color Simulation Guide
Arduino RGB LED Color Simulation Guide
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
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
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: