LED Pattern
Final Setup
LED Strip Circuit Diagram
// 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();
}
}