Skip to content

Instantly share code, notes, and snippets.

@dmadison
dmadison / MIDIvis.ino
Created June 2, 2017 12:57
Basic MIDI Visualizer with Arduino
/*
* Basic MIDI Visualizer
* by David Madison © 2017
* www.partsnotincluded.com
*
* This is a basic MIDI visualizer using addressable LEDs, to demonstrate how
* Arduino's MIDI library works. Playing a note turns an LED on, stopping a note
* turns the LED off. Continuous controllers 21, 22, and 23 adjust the RGB color.
*
*/
// Slightly modified Adalight protocol implementation that uses FastLED
// library (http://fastled.io) for driving WS2811/WS2812 led stripe
// Was tested only with Prismatik software from Lightpack project
#include "FastLED.h"
#define NUM_LEDS 114 // Max LED count
#define LED_PIN 6 // arduino output pin
#define GROUND_PIN 10
#define BRIGHTNESS 255 // maximum brightness
@dmadison
dmadison / Linear RGB Color Blend.ino
Last active December 5, 2016 22:20
Example of a basic RGB color blending function using floats. Takes two packed 32-bit RGB colors and a percentage byte as an input and returns a single 32-bit color as an output.
uint32_t blendRGB(uint32_t c1, uint32_t c2, uint8_t p){
/* Blends two RGB color values using a linear algorithm
* in the form of y = mx + b.
*
* Where y is the resultant blended color (per channel), m
* is the slope of the color change divided by the number of steps,
* x is the current step, and b is the initial channel value.
*
* This implementation uses a single byte for gradation, giving steps from 0-255.
*/