Hey all!
So I am working on a project for school that has LED strip lighting controlled by Arduino. I am using two tutorials- http://www.instructables.com/id/Arduino-Controlled-LED-Strip-Holiday-Lighting/ and Arduino Code | RGB LED Strips | Adafruit Learning System to do it. I also have a Maker Shield for my Uno. I also have connector cable wire, transistors, and LED strips.
The first tutorial calls for only 2 LED strips, but I need to use 3. First off, is it even possible to connect 3 strips to what I have, and if so, how and where exactly would I connect it? The tutorials were a bit vague in describing where to solder. If this isn't possible, what would you recommend I use to make this happen?
And lastly, I want the lights to switch from red to blue (and blue to red) at random intervals. I modified some code from one of the tutorials, and I need to figure out how to make it switch randomly. This is what I have so far:
// Color Changer for 3 Analog LED Strips
// 3 LED strips with R, G, B LEDS on each, so there are 9 channels to control via FET transistors
// use the 9 PWM digital I/O pins for the FET gate pins
#define R1 3
#define G1 5
#define B1 6
#define R2 9
#define G2 10
#define B2 11
#define R3 13
#define G3 14
#define B3 15
#define FADESPEED 7 // make this higher to slow down
void setup() {
// set all the LEDs to off
analogWrite(R1, 0);
analogWrite(G1, 0);
analogWrite(B1, 0);
analogWrite(R2, 0);
analogWrite(G2, 0);
analogWrite(B2, 0);
analogWrite(R3, 0);
analogWrite(G3, 0);
analogWrite(B3, 0);
}
void loop() {
int i;
// fade strip 1 red up and strip 2 red up
for (i = 0; i < 256; i++) {
analogWrite(R1, i);
analogWrite(R2, i);
delay(FADESPEED);
}
// fade strip 1 red down and strip 2 red down
for (i = 0; i < 256; i++) {
analogWrite(R1, 255-i);
analogWrite(R2, 255-i);
delay(FADESPEED);
}
// fade strip 1 blue up and strip 2 blue up
for (i = 0; i < 256; i++) {
analogWrite(B1, i);
analogWrite(B2, i);
delay(FADESPEED);
}
// fade strip 1 blue down and strip 2 blue down
for (i = 0; i < 256; i++) {
analogWrite(B1, 255-i);
analogWrite(B2, 255-i);
delay(FADESPEED);
}
}
Any pointers or corrections would be much appreciated. This is my first time using Arduino. Thank you!