Last active
January 10, 2018 22:27
-
-
Save chemdoc77/efdfb49c9de1b20022eedf8737b657d1 to your computer and use it in GitHub Desktop.
FastLED Sinelon_oneway - creates a dot that goes only forward with a tail.
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
// FastLED Sinelon_oneway by Chemdoc77 | |
// Based on the DemoReel100 example of the FastLED library. | |
// a dot that goes only forward with a tail. | |
#include "FastLED.h" | |
#define NUM_LEDS 100 | |
#define chipset NEOPIXEL | |
#define Data_pin 6 | |
#define BRIGHTEST 40 // the BRIGHTEST range is from 0 to 255. | |
CRGB leds[NUM_LEDS]; | |
//pre-declaration of functions | |
void cd77_sinelon_oneway(); | |
void cd77_sinelon(); | |
void setup() { | |
delay(2000); // power-up safety delay | |
FastLED.addLeds<chipset, Data_pin>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); | |
FastLED.setBrightness(BRIGHTEST); | |
} | |
void loop () { | |
cd77_sinelon_oneway(20, CRGB::Red, 5); | |
} | |
// Functions ====================== | |
// Modification of sinelon() in FastLED's DemoReel100 example | |
void cd77_sinelon_oneway(uint8_t BPM, CRGB color, uint8_t fadeby) | |
{ | |
// a colored dot going in one direction with fading tail | |
fadeToBlackBy( leds, NUM_LEDS, fadeby); //change fadeby to smaller or larger number to adjust the length of the tail. | |
uint8_t u= beat8(BPM,0); //BPM will allow you to adjust the speed the dot is moving. | |
uint16_t pos=map(u,0,255,0,NUM_LEDS); | |
leds[pos] = color; | |
FastLED.show(); | |
} | |
// this function is from FastLED DemoReel100 example | |
void cd77_sinelon(uint8_t BPM, CRGB color ) | |
{ | |
// a colored dot sweeping back and forth, with fading tail | |
fadeToBlackBy( leds, NUM_LEDS, 20); //change 20 to smaller or larger number to adjust the length of the tail. | |
uint16_t pos = beatsin16(BPM,0,NUM_LEDS); //BPM will allow you to adjust the speed the dot is moving. | |
leds[pos] = color; | |
FastLED.show(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment