Created
April 14, 2016 17:57
-
-
Save gatana/1272e28171e8b06ec5be98b6b73ed513 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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