/********* Pleasedontcode.com **********
Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- Terms and Conditions:
You have a non-exclusive, revocable, worldwide, royalty-free license
for personal and commercial use. Attribution is optional; modifications
are allowed, but you're responsible for code maintenance. We're not
liable for any loss or damage. For full terms,
please visit pleasedontcode.com/termsandconditions.
- Project: **MIDI Feedback**
- Source Code NOT compiled for: Arduino Pro Mini 5V
- Source Code created on: 2025-06-09 20:47:51
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* Utilizes MIDIUSB library to create a MIDI */
/* controller that can send note and control change */
/* messages, allowing integration with various MIDI- */
/* compatible software and hardware. */
/****** END SYSTEM REQUIREMENTS *****/
/* START CODE */
/****** DEFINITION OF LIBRARIES *****/
#include <MIDIUSB.h> //https://github.com/arduino-libraries/MIDIUSB
#include <Adafruit_NeoPixel.h> // NeoPixel library
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
#define NUM_BUTTONS 1 // number of buttons on the controller
#define BUTTON_PIN 2 // pin connected to the buttons
#define NUM_PIXELS 1 // number of NeoPixels on the controller
#define PIXEL_PIN 5 // pin connected to the NeoPixels
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_PIXELS, PIXEL_PIN, NEO_GRB + NEO_KHZ800); // initialize NeoPixel object
int buttonState[NUM_BUTTONS]; // array to store button states
int lastButtonState[NUM_BUTTONS]; // array to store last button states
void setup(void)
{
// put your setup code here, to run once:
MIDI.begin(); // initialize MIDI communication
pinMode(BUTTON_PIN, INPUT_PULLUP); // set button pin as input with internal pull-up resistor
pixels.begin(); // initialize NeoPixels
}
void loop(void)
{
// put your main code here, to run repeatedly:
for (int i = 0; i < NUM_BUTTONS; i++) { // loop through all buttons
buttonState[i] = digitalRead(BUTTON_PIN + i); // read button state
if (buttonState[i] != lastButtonState[i]) { // if button state has changed
if (buttonState[i] == LOW) { // if button is pressed
pixels.setPixelColor(i, pixels.Color(255, 255, 255)); // set NeoPixel color to white
MIDI.sendNoteOn(i + 60, 127, 1); // send MIDI note on message with note number and velocity
} else { // if button is released
pixels.setPixelColor(i, pixels.Color(0, 0, 0)); // turn off NeoPixel
MIDI.sendNoteOff(i + 60, 0, 1); // send MIDI note off message with note number and velocity
}
pixels.show(); // update NeoPixels
}
lastButtonState[i] = buttonState[i]; // store current button state as last button state
}
}
/* END CODE */