Hi there,
Any advice I could get would be most appreciated! I am a total noob with coding and electronics. For my first project I am hoping to control some LED strips with an Arduino Uno. I can't work out whether my issue is with the coding or wiring.
I have purchased WS2818B LED Strips (30 LEDs per meter). The pads are 5V, DI/DO, and GND. Very similar to this: Pololu - Addressable RGB 60-LED Strip, 5V, 2m (WS2812B)
I am running an Arduino Uno.
I have wired up according to the attached picture. Basically, I have plugged a USB cable into an iPhone adapter, which is then plugged into the mains. I have stripped the other end of the cable, and have attached the ground and power wires to a terminal block. The other end of the terminal block is attached to the auxiliary power cables for my LEDs.
The code is copied below.
I have managed to get one LED to light up green, and three others to light up blue (both solid). However, when I unplugged this arrangement and plugged it in again, the LEDs did not light up again.
I am not sure whether this is a problem with wiring, or code, or both.
Any advice would be most appreciated!
Thanks,
Marty
// color swirl! connect an RGB LED to the PWM pins as indicated
// in the #defines
// public domain, enjoy!
#define REDPIN 5
#define GREENPIN 6
#define BLUEPIN 3
#define FADESPEED 5 // make this higher to slow down
void setup() {
pinMode(REDPIN, OUTPUT);
pinMode(GREENPIN, OUTPUT);
pinMode(BLUEPIN, OUTPUT);
}
void loop() {
int r, g, b;
// fade from blue to violet
for (r = 0; r < 256; r++) {
analogWrite(REDPIN, r);
delay(2);
}
// fade from violet to red
for (b = 255; b > 0; b--) {
analogWrite(BLUEPIN, b);
delay(1);
}
// fade from red to yellow
for (g = 0; g < 256; g++) {
analogWrite(GREENPIN, g);
delay(FADESPEED);
}
// fade from yellow to green
for (r = 255; r > 0; r--) {
analogWrite(REDPIN, r);
delay(FADESPEED);
}
// fade from green to teal
for (b = 0; b < 256; b++) {
analogWrite(BLUEPIN, b);
delay(FADESPEED);
}
// fade from teal to blue
for (g = 255; g > 0; g--) {
analogWrite(GREENPIN, g);
delay(FADESPEED);
}
}