Skip to content

Instantly share code, notes, and snippets.

@StefanPetrick
StefanPetrick / Test.ino
Last active August 29, 2015 14:10
Test
//It will swap part B and C:
void SortMyLeds() {
for (byte i=20; i < 30; i++) {
CRGB buffer = leds[i];
leds[i] = leds[i-10];
leds[i-10] = buffer;
}
}
@StefanPetrick
StefanPetrick / golden spiral
Last active August 29, 2015 14:16
golden spiral
int width = 300; // crop window resolution
int height = 550;
int centerX = int(width * 0.72); // precalculated centre of the spiral
int centerY = int(height * 0.72);
float e = 2.71828; // Eulers number
void setup() { // just relevant for Processing
size(width, height);
#include<FastLED.h>
#define REDPIN 3
#define GREENPIN 6
#define BLUEPIN 9
#define NUM_LEDS 1
//#define LED_PIN 12
//#define BRIGHTNESS 255
//#define LED_TYPE WS2812
@StefanPetrick
StefanPetrick / FunkyNoise.ino
Last active March 8, 2017 01:56
FunkyNoise alpha version
/*
FunkyNoise 1.0
----------------
A Collection Of
Animations
And Helper Functions
for two dimensional led effects
on the 32x32 SmartMatrix.
@StefanPetrick
StefanPetrick / crosswipe
Created December 6, 2014 15:59
cross wipe
// the animation itself
// basically just moves the noise in 2 dimensions
// and oscillates the border for the mapping methods
void CrossNoise2() {
currentPalette = RainbowStripeColors_p;
noisesmoothing = 20;
y[0] += 100;
#include<FastLED.h>
#define LED_PIN 12
#define BRIGHTNESS 255
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
#define NUM_LEDS (240)
CRGB leds[NUM_LEDS];
// as showed on youtube
void noise_audio2() {
read_audio();
CRGBPalette16 Pal( pit3 ); // the red one
y[0] += (bands[4] - 10) * 4;
scale_x[0] = 10000 - (bands[0] * 40);
scale_y[0] = scale_x[0];
byte layer = 0;
for (uint8_t i = 0; i < Width; i++) {
uint32_t ioffset = scale_x[layer] * (i - CentreX);
@StefanPetrick
StefanPetrick / sinusoid3
Created July 19, 2017 15:21
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;
@StefanPetrick
StefanPetrick / NoiseSmearing
Created January 11, 2015 10:24
dirty testcode
#include<SmartMatrix.h>
#include<FastLED.h>
#define kMatrixWidth 32
#define kMatrixHeight 32
byte CentreX = (kMatrixWidth / 2) - 1;
byte CentreY = (kMatrixHeight / 2) - 1;
#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
@StefanPetrick
StefanPetrick / Noise_smoooooth.ino
Last active April 6, 2022 18:31
Proof of concept for smooth fading
/*
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"