Skip to content

Instantly share code, notes, and snippets.

@gatana
Created April 14, 2016 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gatana/1272e28171e8b06ec5be98b6b73ed513 to your computer and use it in GitHub Desktop.
Save gatana/1272e28171e8b06ec5be98b6b73ed513 to your computer and use it in GitHub Desktop.
#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--;
}
} }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment