Tuner30ansFlorida/tuner30ans.ino

44 lines
1.3 KiB
C++

//Import the needed FastLED library
#include <FastLED.h>
#include <MIDIElements.h>
//These variables allow you to specify how the strip will behave
#define NUM_LEDS 12 //This number decides how many of the strip's LEDs the code will use
const int ledLength = 1; //This number decides how many LEDs will be turned on at once
boolean debug = false; // print to serial instead of midi
boolean secondary = true; // enable secondary midi messages
int midiChannel = 1; // midi channel number
//Define and initiate global variables
CRGB leds[NUM_LEDS];
#define DATA_PIN 16
int sensorPin = 7;
int ledValue;
int sensorValue;
Potentiometer pot(sensorPin, midiChannel, 3, secondary, debug); // knob on pin 45 (A7)
void setup() {
// initiate the LED strip
FastLED.addLeds<WS2811, DATA_PIN>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
pinMode(sensorPin, INPUT);
}
void loop() {
pot.read(); // read knob and send midi messages
//Read value from any sensor
sensorValue = analogRead(sensorPin);
//Using the map function, we can take any sesor input and align it to a location on the LED strip
ledValue = map(sensorValue, 1023, 0, 0, NUM_LEDS);
//Clear previous configuration
FastLED.clear();
//Set and turn on desired LED
leds[ledValue] = CRGB::White;
FastLED.show();
usbMIDI.read(); // read all the incoming midi messages
}