Function one shows a single pixel traveling up the LED strip.
The Real Quick Runner goes quite a bit faster.
Below shows the four pixel fading trail. From the code you can see I just needed to change:
int pos = beatsin16(10, 0, NUM_LEDS);
the ten as the first argument to an 8 to create a 3 pixel fade.
Midway the LED switches colors from purple to blue.
Function 5:
HSV dimming trail of changing colors
#include "FastLED.h" | |
// How many leds in your strip? | |
#define NUM_LEDS 15 | |
// For led chips like Neopixels, which have a data line, ground, and power, you just | |
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock, | |
// ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN | |
#define DATA_PIN 5 | |
#define CLOCK_PIN 6 | |
// Define the array of leds | |
CRGB leds[NUM_LEDS]; | |
unsigned long bounces; | |
unsigned int timeDelay = 300; | |
void setup() { | |
Serial.begin(57600); | |
Serial.println("resetting"); | |
// Change depending on the LED strip model | |
LEDS.addLeds<DOTSTAR, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); | |
LEDS.setBrightness(84); | |
} | |
void loop() { | |
static uint8_t hue = 0; | |
Serial.print("x"); | |
// every 4 bounces or 2 loops | |
if (bounces%2 == 0) { | |
// now supports 4.25 colors! | |
hue = hue + 60; | |
} | |
// First slide the led in one direction | |
for(int i = 0; i < NUM_LEDS; i++) { | |
// if it passes half way | |
if (i+4 == NUM_LEDS/2) { | |
// now supports 4.25 colors! | |
hue = hue + 60; | |
} | |
leds[i] = CHSV(hue, 255, (255/5)*1); | |
leds[i+1] = CHSV(hue, 255, (255/5)*2); | |
leds[i+2] = CHSV(hue, 255, (255/5)*3); | |
leds[i+3] = CHSV(hue, 255, (255/5)*4); | |
leds[i+4] = CHSV(hue, 255, 255); | |
hue++; | |
// Show the leds | |
FastLED.show(); | |
// go Back to Black | |
leds[i] = CRGB::Black; | |
delay(timeDelay); | |
} | |
// // then slide the LED into the other direction | |
for(int i = (NUM_LEDS)-1; i >= 0; i--) { | |
// // if it passes half way | |
// if (i == NUM_LEDS/2) { | |
// // now supports 4.25 colors! | |
// hue = hue + 60; | |
// } | |
leds[i] = CHSV(hue, 255, 255); | |
leds[i+1] = CHSV(hue, 255, (255/5)*4); | |
leds[i+2] = CHSV(hue, 255, (255/5)*3); | |
leds[i+3] = CHSV(hue, 255, (255/5)*2); | |
leds[i+4] = CHSV(hue, 255, (255/5)*1); | |
hue++; | |
// Show the leds | |
FastLED.show(); | |
// go Back to Black | |
leds[i+4] = CRGB::Black; | |
delay(timeDelay); | |
} | |
// count as a bounce | |
bounces ++; | |
} |
Lightning
#include "FastLED.h" | |
#define DATA_PIN 5 | |
#define CLOCK_PIN 6 | |
#define LED_TYPE DOTSTAR | |
#define COLOR_ORDER GRB | |
#define NUM_LEDS 15 | |
CRGB leds[NUM_LEDS]; | |
//#define BRIGHTNESS 96 | |
#define BRIGHTNESS 50 | |
#define FRAMES_PER_SECOND 120 | |
int hit; | |
const int buttonPin = 2; | |
int buttonPushCounter = 0; | |
int buttonState = 0; | |
int lastButtonState = 0; | |
uint8_t gHue = 0; // rotating "base color" used by many of the patterns | |
void setup() { | |
pinMode(buttonPin, INPUT); | |
delay(300); // 3 second delay for recovery | |
LEDS.addLeds<DOTSTAR, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); | |
// set master brightness control | |
FastLED.setBrightness(BRIGHTNESS); | |
Serial.begin(9600); | |
} | |
void loop() { | |
buttonState = digitalRead(buttonPin); | |
Serial.print(buttonState); | |
if (buttonState != lastButtonState) { | |
if (buttonState == HIGH) { | |
buttonPushCounter++; | |
Serial.println("on"); | |
Serial.println(buttonPushCounter); | |
} else { | |
Serial.println("off"); | |
} | |
} | |
lastButtonState = buttonState; | |
FastLED.show(); | |
FastLED.delay(100 / FRAMES_PER_SECOND); | |
if (hit % 4 == 0) { | |
gHue++; | |
} | |
// use for | |
// EVERY_N_MILLISECONDS( 20 ) { | |
// gHue++; // slowly cycle the "base color" through the rainbow | |
// } | |
} | |
void beautiful() | |
{ | |
fadeToBlackBy(leds, NUM_LEDS, 20); | |
int pos = beatsin8(10, 0, NUM_LEDS); | |
leds[pos] += CHSV(gHue, 255, 192); | |
if (pos == 1 || pos == 15) { | |
hit++; | |
} | |
FastLED.show(); | |
FastLED.delay(100 / FRAMES_PER_SECOND); | |
if (hit % 4 == 0) { | |
gHue++; | |
} | |
} |
I had a lot of trouble simply getting the LED strip to not be finicky. I used two 330 resistors for the data and clock pins but found that the slightest movements on the table or even a door banging shut would render my pixels frozen. I ended up jamming some extra jumpers to hold the resistors still. I also had to solder the strip connections twice because the jumpers would fall from the carefully soldered ports.
#include "FastLED.h" | |
FASTLED_USING_NAMESPACE | |
// How many leds are in the strip? | |
#define NUM_LEDS 15 | |
// Data pin that led data will be written out over | |
#define DATA_PIN 6 | |
// Clock pin only needed for SPI based chipsets when not using hardware SPI | |
#define CLOCK_PIN 5 | |
// This is an array of leds. One item for each led in your strip. | |
CRGB leds[NUM_LEDS]; | |
#define LED_TYPE DOTSTAR | |
#define COLOR_ORDER GRB | |
#define BRIGHTNESS 96 | |
#define FRAMES_PER_SECOND 120 | |
uint8_t gHue; // rotating "base color" used by many of the patterns | |
void setup() { | |
// put your setup code here, to run once: | |
FastLED.addLeds<DOTSTAR, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); | |
} | |
void fadeall() { | |
for (int i = 0; i < NUM_LEDS; i++) { | |
leds[i].nscale8(250); | |
} | |
} | |
void loop() { | |
sinelon(); | |
// send the 'leds' array out to the actual LED strip | |
FastLED.show(); | |
// insert a delay to keep the framerate modest | |
FastLED.delay(1000 / FRAMES_PER_SECOND); | |
// do some periodic updates | |
// EVERY_N_MILLISECONDS( 20 ) { | |
// gHue++; // slowly cycle the "base color" through the rainbow | |
// } | |
} | |
// FUNCTION ONE: One pixel moving down the strip | |
// static uint8_t hue = 0; | |
// Serial.print("x"); | |
// // First slide the led in one direction | |
// for(int i = 0; i < NUM_LEDS;i++) { | |
// // Set the i'th led to red | |
// leds[i] = CHSV(hue++, 255, 255); | |
// // Show the leds | |
// FastLED.show(); | |
// leds[i] = CRGB::Black; | |
// fadeall(); | |
// delay(100); | |
// } | |
// put your main code here, to run repeatedly: | |
//FUNCTION TWO | |
//void sinelon() | |
//{ | |
// // a colored dot sweeping back and forth, with fading trails | |
// fadeToBlackBy( leds, NUM_LEDS, 20); | |
// int pos = beatsin16(10,0,NUM_LEDS); | |
// leds[pos] += CHSV( gHue, 255, 192); | |
//} | |
//// //FUNCTION THREE | |
//void sinelon() { | |
// // a colored dot sweeping back and forth, with fading trails | |
// fadeToBlackBy( leds, NUM_LEDS, 20); | |
// int pos = beatsin16(8, 0, NUM_LEDS); | |
// leds[pos] += CHSV(gHue, 100, 192); | |
// | |
// | |
//} | |
// | |
// | |
////FUNCTION FOUR | |
//void sinelon() { | |
// // a colored dot sweeping back and forth, with fading trails | |
// fadeToBlackBy( leds, NUM_LEDS, 20); | |
// int pos = beatsin16(10, 0, NUM_LEDS); | |
// leds[pos] += CHSV(gHue, 200, 192); | |
// | |
// if (pos >= 7) { | |
// gHue = 250; | |
// } else { | |
// gHue = 50; | |
// } | |
// | |
//} | |
// FUNCTION FIVE :One pixel with a tail, fading in 4 pixels | |
//and bouncing 4 times and incrementing its HSV value by one for each step taken | |
void sinelon() { | |
int hue; | |
int value = 10; | |
int sat = 70; | |
fadeToBlackBy( leds, NUM_LEDS, 20); | |
int pos = beatsin16(10, 0, NUM_LEDS); | |
for(int i = 0; i > NUM_LEDS;i++) { | |
leds[i] = CHSV(hue++, value++, sat++); | |
if (pos == 15) { | |
value--; | |
} | |
} } | |
Function one shows a single pixel traveling up the LED strip. The Real Quick Runner goes quite a bit…
agario unblocked
Function one shows a single pixel traveling up the
agario unblocked