#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
float floatMap(float x, float in_min, float in_max, float out_min, float out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(115200);
MIDI.begin(MIDI_CHANNEL_OMNI); // Listen to all incoming messages
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin GPIO12:
int analogValue = analogRead(12);
// Rescale to midi value (0-128):
float value = map(analogValue, 0, 8192, 0, 128);
// print out the value you read:
Serial.print("Analog: ");
Serial.print(analogValue);
Serial.print(", MIDI Value: ");
Serial.println(value);
delay(200);
}
Loading
esp32-s2-devkitm-1
esp32-s2-devkitm-1