Hardware Reference
In-Depth Information
Since the RGB strip requires 12 V, we must use a transistor switching circuit to control the
LEDs. The transistor switching circuit for controlling the Red, Green, and Blue channels of
the LED strip is shown in the following diagram:
The Arduino RGB switching circuit
The RGB channels are connected to the NPN transistors that act as switches. The base of
the transistor is connected to the PWM ( Pulse Width Modulaion ) output of the Arduino.
This enables you to adjust the brightness of the RGB channels, and consequently, produce
different colors.
Engage thrusters
1. Adafruit has provided an example for adjusing the brightness of the LEDs and
producing diferent colors from the combinaion of primary colors. Let's consider
the following piece of code:
// fade from blue to violet
for (r = 0; r < 256; r++) {
analogWrite(REDPIN, r);
delay(FADESPEED);
}
// fade from violet to red
for (b = 255; b > 0; b--) {
analogWrite(BLUEPIN, b);
delay(FADESPEED);
}
 
Search WWH ::




Custom Search