Many electronics such as
videogame consoles use RGB
LEDs to have the versatility
to show different colors in
the same area. Often times
the diffent colors represent
different states of working
condition.
Circuit 2
Arduino Code:
3
Troubleshooting:
LED Remains Dark or Shows Incorrect Color
With the four pins of the LED so close together, it’s
sometimes easy to misplace one. Double check each
pin is where it should be.
Seeing Red
The red diode within the RGB LED may be a bit brighter
than the other two. To make your colors more balanced,
use a higher Ohm resistor. Or adjust in code.
analogWrite(RED_PIN, redIntensity);
to
analogWrite(RED_PIN, redIntensity/3);
You should see your LED turn on,
but this time in new, crazy colors! If it
isn't, make sure you have assembled
the circuit correctly and verified and
uploaded the code to your board or
see the troubleshooting tips below.
Code to Note:
Real World Application:
Open Arduino IDE
//
File > Examples > SIK Guide >
Circuit # 3
What you Should See:
A for() loop is used to step a number across a range, and repeatedly runs
code within the brackets {}. Here the variable "x" starts a 0, ends at 767,
and increases by one each time ("x++").
for (x = 0; x < 768; x++)
{}
The RedBoard is very very fast, capable of running thousands of lines of
code each second. To slow it down so that we can see what it's doing,
we'll often insert delays into the code. delay() counts in milliseconds;
there are 1000 ms in one second.
delay(sensorValue);
"If / else" statements are used to make choices in your programs. The statement
within the parenthesis () is evaluated; if it's true, the code within the first brackets {}
will run. If it's not true, the code within the second brackets {} will run.
if (x <= 255)
{}
else
{}
IOREF
RES
ET
RESET
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
1
0
TX
RX
13
3.3V
5V
GND
GND
VIN
A0
A1
A2
A3
A4
A5
POWER
ANALOG IN
DIGIT
AL (PWM~)
ON
ISP
TX
RX
IOREF
RES
ET
RESET
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
1
0
TX
RX
13
3.3V
5V
GND
GND
VIN
A0
A1
A2
A3
A4
A5
POWER
ANALOG IN
DIGIT
AL (PWM~)
ON
ISP
TX
RX
LEARN. SHARE. HACK.
Page 32
Summary of Contents for RedBoard
Page 13: ...Page 11...