Skip to content

Instantly share code, notes, and snippets.

@gnkarn
gnkarn / fastled_snippets
Created April 9, 2019 15:29
fastled snippets from a tuline
/* My FastLED Tips, Tricks and Traps
By: Andrew Tuline
Date: July, 2015
Note: This is a TEXT file and not a program. It has a .h extension so that it looks like code in an IDE. It's not.
References:
https://github.com/FastLED/FastLED/wiki/Overview
http://fastled.io/docs/3.1/modules.html
*/
@gnkarn
gnkarn / Fire2018-2.ino
Created October 31, 2018 10:42 — forked from StefanPetrick/Fire2018-2.ino
Fire effect v2.0 for FastLED matrix
#include "FastLED.h"
// matrix size
uint8_t Width = 16;
uint8_t Height = 16;
uint8_t CentreX = (Width / 2) - 1;
uint8_t CentreY = (Height / 2) - 1;
// NUM_LEDS = Width * Height
#define NUM_LEDS 256
@gnkarn
gnkarn / matrixEffect.ino
Created August 26, 2017 03:06 — forked from Jerware/matrixEffect.ino
Matrix LED Effect using FastLED
// Matrix effect by Jeremy Williams
// Designed for Game Frame
// http://www.ledseq.com
#include <FastLED.h>
// LED setup
#define kMatrixWidth 16
#define kMatrixHeight 16
#define DATA_PIN 2
@gnkarn
gnkarn / sinusoid3
Created July 20, 2017 01:39 — forked from StefanPetrick/sinusoid3
RGB Sinusoids
float speed = 0.3; // speed of the movement along the Lissajous curves
float size = 3; // amplitude of the curves
for (uint8_t y = 0; y < Height; y++) {
for (uint8_t x = 0; x < Width; x++) {
float cx = y + float(size * (sinf (float(speed * 0.003 * float(millis() ))) ) ) - 8; // the 8 centers the middle on a 16x16
float cy = x + float(size * (cosf (float(speed * 0.0022 * float(millis()))) ) ) - 8;
float v = 127 * (1 + sinf ( sqrtf ( ((cx * cx) + (cy * cy)) ) ));
uint8_t data = v;
@gnkarn
gnkarn / ColorFromPalette12.ino
Created June 29, 2017 11:20 — forked from morningdew76/ColorFromPalette12.ino
ColorFromPalette12, a 12-bit ColorFromPalette function
CRGB ColorFromPalette12(CRGBPalette16 pal, uint16_t index, uint8_t brightness, TBlendType blendType) {
//index is a 12-bit number, range 0-4095
//uint8_t hi4 = lsrX4(index);
//uint8_t lo4 = index & 0x0F;
uint8_t hi4 = (index & 0x0F00) >> 8; //***shift 8 bits to the right instead of 4
uint8_t lo8 = index & 0xFF; //***keep right 8 bytes instead of right 4 bytes
// const CRGB* entry = &(pal[0]) + hi4;
// since hi4 is always 0..15, hi4 * sizeof(CRGB) can be a single-byte value,
@gnkarn
gnkarn / noise_noise.ino
Created June 28, 2017 03:24 — forked from StefanPetrick/noise_noise.ino
The complete code for the noise controlled noise.
/*
A FastLED matrix example:
A simplex noise field fully modulated and controlled by itself
written by
Stefan Petrick 2017
Do with it whatever you like and show your results to the FastLED community
https://plus.google.com/communities/109127054924227823508
*/
#include "FastLED.h"
@gnkarn
gnkarn / noise_noise.ino
Created June 24, 2017 15:22 — forked from StefanPetrick/noise_noise.ino
FastLED simplex noise and colormapping fully modulated by itself
void noise_noise1() {
CRGBPalette16 Pal( pit );
/* here is how the palette looks like:
DEFINE_GRADIENT_PALETTE( pit ) {
0, 3, 3, 3,
64, 13, 13, 255, // blue
128, 3, 3, 3,
192, 255, 130, 3, // orange
@gnkarn
gnkarn / gist:df9e0a098fea228ff173
Last active August 29, 2015 14:24
Noise smear test , teensy 3.1 , 2812b leds , serpentine , 30x8 rectangular layout
//#include<SmartMatrix.h>
#include<FastLED.h>
// NoiseSmearing by Stefan Petrick: https://gist.github.com/StefanPetrick/9ee2f677dbff64e3ba7a
// Timed playlist code is from Mark Kriegsman's TimedPlaylist demo here: https://gist.github.com/kriegsman/841c8cd66ed40c6ecaae
// Palette cross-fading is from Mark Kriegsman's demo here: https://gist.github.com/kriegsman/1f7ccbbfa492a73c015e
#if FASTLED_VERSION < 3001000