Home

Contact Me





LinkedIn

1.0 Background


The following is a "smart" LED light strip. Each LED is individually addressable, making color and timing control possible with a microcontroller. I used an Arduino Uno to code the following light pattern. You can view the video on my YouTube Channel.

2.0 Final Product


LED Pattern


Final Setup


3.0 Circuit Diagram

Schematic

LED Strip Circuit Diagram

4.0 Assembly



Materials

REAL Arduino Uno

*Always read reviews and ensure you are not buying a
cheap knockoff Arduino.
Fakes will NOT interface with the Arduino IDE properly


Neopixel LED Strip
9V Battery
5V/2A Power Source
Soldering Iron
Latch Button
22 AWG Wire*

*Any type of wire between 20-22AWG work for Arduino.
I prefer solid to stranded wire for ease of
soldering, but that is personal preference.

5.0 Code

  

// NeoPixel test program showing use of the WHITE channel for RGBW
// pixels only (won't look correct on regular RGB NeoPixel strips).

#include 
#include 


// Which pin on the Arduino is connected to the NeoPixels?
#define LED_PIN     6 //Connect D6 on Arduino Uno to NeoPixel input (white wire)

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT  30

#define BRIGHTNESS 255 // NeoPixel brightness, 0 (min) to 255 (max)




// Declare our NeoPixel strip object:


Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)

uint32_t rgbcolor1; //variable for color of NeoPixel
uint32_t rgbcolor2; //variable for color of NeoPixel
  uint32_t hue1 = 0; //randomized hue variable for HSV (Hue, Saturation, Value)
  uint32_t hue2 = 0; //randomized hue variable for HSV (Hue, Saturation, Value)
  uint8_t saturation = 0; //initialize saturation for HSV (Hue, Saturation, Value)
//Saturation determines the intensity or purity of the color…this is an 
//8-bit number ranging from 0 (no saturation, just grayscale) 
//to 255 (maximum saturation, pure hue). In the middle,
//you’ll start to get sort of pastel tones.


  uint8_t value= 0; //Value determines the brightness of a color…
//it’s also an 8-bit number ranging from 0 (black, regardless of hue or saturation) 
//to 255 (maximum brightness).

long maxValue = 65535; //max hue value for HSV
//red (0) --> Violet (65535) in ROYGBIV order

void setup() {
  Serial.begin(9600); //begin serial communication with strip at 9600 Baude Rate
  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.clear(); //clear the strip
  strip.setBrightness(BRIGHTNESS); //set brightness
  hue1 = random(0, maxValue); //
  value = 255; //set desired brightness (0-->255)
  saturation = 150; //set desired saturation (0--> 255), 150 will be pastel tones
  
  rgbcolor1 = strip.gamma32(strip.ColorHSV(hue1, saturation, value)); 
  //Strip.ColorHSV will utilize HSV color library
  //strip.gamma32 will help crispen the HSV colors. 
  //without strip.gamma32 your HSV colors may be washed out
  
  strip.fill(rgbcolor1, 0, 29); //fill the strip with the rgb color
  //from 0 (first pixel) to 29 (last pixel)
  strip.show(); //show the color
  pinMode(LED_PIN, OUTPUT); //define D6 as an output pin

}

void loop() {
  hue1 = random(maxValue/2, maxValue); //generate random hue
  value = 255; //set desired brightness (0-->255)
  saturation = random(150,255); //set desired saturation (0--> 255), 150 will be pastel tones
  
  rgbcolor1 = strip.gamma32(strip.ColorHSV(hue1, saturation, value));
    //Strip.ColorHSV will utilize HSV color library
  //strip.gamma32 will help crispen the HSV colors. 
  //without strip.gamma32 your HSV colors may be washed out


  //Loop that starts at middle of strip (LED #15)
  //and expands outward towards each edge of the strip
  //one LED at a time
  for (int i = 0; i <= 15; i++) { 
    strip.fill(rgbcolor1, 15 - i, 1);
    strip.fill(rgbcolor1, 15 + i, 1);
    //short delay so each LED illuminates individually
    delay(100); 
    //show your pretty colors!
    strip.show();
  }
    hue2 = random(0, maxValue/2); //generate random hue
  value = 255; //set desired brightness (0-->255)
  saturation = random(100,255); //set desired saturation (0--> 255), 150 will be pastel tones
  
  rgbcolor2 = strip.gamma32(strip.ColorHSV(hue2, saturation, value));
    //Strip.ColorHSV will utilize HSV color library
  //strip.gamma32 will help crispen the HSV colors. 
  //without strip.gamma32 your HSV colors may be washed out


  //Loop that starts at ends of strip (LED #15)
  //and travels inward towards strip center
  //one LED at a time
  for (int i = 15; i >= 0; i--) { 
    strip.fill(rgbcolor2, 15 - i, 1);
    strip.fill(rgbcolor2, 15 + i, 1);
    //short delay so each LED illuminates individually
    delay(100); 
    //show your pretty colors!
    strip.show();
  }



}