Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <MIDI.h>
- #include <FastLED.h>
- MIDI_CREATE_DEFAULT_INSTANCE();
- #define LED_PIN 12
- #define NUM_LEDS 110
- #define BRIGHTNESS 64
- #define LED_TYPE WS2811
- #define COLOR_ORDER GRB
- CRGB leds[NUM_LEDS];
- CRGBPalette16 currentPalette;
- TBlendType currentBlending;
- int diodes[110] = {0, 109, 1, 108, 2, 3, 106, 4, 105, 5, 104, 6,
- 7, 102, 8, 101, 9, 10, 99, 11, 98, 12, 97, 13,
- 14, 95, 15, 94, 16, 17, 92, 18, 91, 19, 90, 20,
- 21, 88, 22, 87, 23, 24, 85, 25, 84, 26, 83, 27,
- 28, 81, 29, 80, 30, 31, 78, 32, 77, 33, 76, 34,
- 35, 74, 36, 73, 37, 38, 71, 39, 70, 40, 69, 41,
- 42, 67, 43, 66, 44, 45, 64, 46, 63, 47, 62, 48,
- 49, 60, 50, 59, 51, 52, 57, 53, 56, 54, 55
- };
- void setup()
- {
- pinMode(11, OUTPUT);
- MIDI.begin();
- digitalWrite(11, HIGH);
- delay( 3000 ); // power-up safety delay
- FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
- FastLED.setBrightness( BRIGHTNESS );
- currentPalette = RainbowColors_p;
- currentBlending = LINEARBLEND;
- }
- void loop()
- {
- uint8_t brightness = 120;
- if (MIDI.read())
- {
- if (MIDI.getType()== midi::NoteOn)
- {
- long int i = MIDI.getData1();
- if(diodes[i] < 55)
- currentPalette = CRGBPalette16(
- CRGB::White, CRGB::White, CRGB::White, CRGB::White,
- CRGB::White, CRGB::White, CRGB::White, CRGB::White,
- CRGB::White, CRGB::White, CRGB::White, CRGB::White,
- CRGB::White, CRGB::White, CRGB::White, CRGB::White
- );
- else
- currentPalette = CRGBPalette16(
- CHSV( HUE_BLUE, 255, 255), CHSV( HUE_BLUE, 255, 255), CHSV( HUE_BLUE, 255, 255), CHSV( HUE_BLUE, 255, 255),
- CHSV( HUE_BLUE, 255, 255), CHSV( HUE_BLUE, 255, 255), CHSV( HUE_BLUE, 255, 255), CHSV( HUE_BLUE, 255, 255),
- CHSV( HUE_BLUE, 255, 255), CHSV( HUE_BLUE, 255, 255), CHSV( HUE_BLUE, 255, 255), CHSV( HUE_BLUE, 255, 255),
- CHSV( HUE_BLUE, 255, 255), CHSV( HUE_BLUE, 255, 255), CHSV( HUE_BLUE, 255, 255), CHSV( HUE_BLUE, 255, 255)
- );
- leds[diodes[i]] = ColorFromPalette( currentPalette, 90, brightness, currentBlending);
- }
- if (MIDI.getType()== midi::NoteOff)
- {
- int i = MIDI.getData1();
- leds[diodes[i]] = ColorFromPalette( currentPalette,90, 0, currentBlending);
- }
- FastLED.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement