Example Code for Arduino-RGB Waterfall

Three colors of RGB will repeatedly show up to form waterfall lighting effect. You can easily use it with Arduino to DIY your favorite lighting effect.

Hardware Preparation

Software Preparation

Wiring Diagram

Connection

Note: For brighter lighting or cascading multiple LED strips, please power them externally since UNO board may not provide enough current.

Other Preparation Work

Ensure the LED Strip Library is installed correctly and hardware connections match the Wiring Diagram. Prepare an external 5V power supply if using multiple strips or requiring brighter output.

Sample Code

#include <FastLED.h>
#define LED_PIN     10
#define NUM_LEDS    166
CRGB leds[NUM_LEDS];
void setup() {
  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
}
void loop() {
  for (int i = 0; i <= 166; i++) {         //Red goes one round
    leds[i] = CRGB ( 255, 0, 0);
    FastLED.show();
    delay(5);
  }
  for (int i = 0; i <= 166; i++) {         //Green goes one round 
    leds[i] = CRGB ( 0, 255, 0);
    FastLED.show();
    delay(5);
  }
  for (int i = 0; i <= 166; i++) {         //Blue goes one round 
    leds[i] = CRGB ( 0, 0, 255);
    FastLED.show();
    delay(5);
  }
}

Result

Three colors of RGB will repeatedly show up to form waterfall lighting effect.

Was this article helpful?

TOP