You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi guys, There is still very little information about these ESP32 S3 boards. I got one to test and I think I can confirm this library is working with the I have. Here is the sketch I used to test it.
Button on pin 4 and GND. When pressed it should send Program Change and Control Change messages, as well as toggle the LED.
Receiving Program Change 10 on any channel will turn the LED ON.
Receiving Program Change 20 on any channel will turn the LED OFF.
This is an example of how we would use basic midi in and out in real life when building midi controllers. Some examples do not show that.
I hope this helps.
To the project owner. If you want I could post a couple more real life examples ;)
Thanks for this amazing library.
#include <BLEMIDI_Transport.h>
#include <hardware/BLEMIDI_ESP32_NimBLE.h>
BLEMIDI_CREATE_INSTANCE("Your_Device_Name", MIDI)
#define DEBOUNCE 20
const int numberButtons = 2;
int button[numberButtons] = {4, 5};
byte buttons[] = {4, 5};
byte pressed[numberButtons], justpressed[numberButtons], ShortPress[numberButtons], LongPress[numberButtons];
bool LedState = false;
void setup()
{
for (int x = 0; x < numberButtons; x++)
{
pinMode(button[x], INPUT_PULLUP);
}
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
// BLEMIDI.setHandleConnected(OnConnected);
// BLEMIDI.setHandleDisconnected(OnDisconnected);
MIDI.begin(MIDI_CHANNEL_OMNI);
MIDI.setHandleProgramChange(MyProgramChange);
}
void MyProgramChange(byte channel, byte program) {
if(program == 10) digitalWrite(LED_BUILTIN, HIGH);
else if(program == 20) digitalWrite(LED_BUILTIN, LOW);
}
void loop()
{
MIDI.read();
check_switches();
if(ShortPress[0]) {
MIDI.sendProgramChange(25, 2);
MIDI.sendControlChange(69, 57, 7);
LedState = !LedState;
digitalWrite(LED_BUILTIN, LedState);
delay(20);
}
}
void check_switches()
{
static byte previousstate[numberButtons];
static byte currentstate[numberButtons];
static long lasttime;
static long Timelapse = 500;
static long TimelapsePset = 450;
static long Timestart;
byte index;
if (millis() < lasttime) { // we wrapped around, lets just try again
lasttime = millis();
}
if ((lasttime + DEBOUNCE) > millis()) { // not enough time has passed to debounce
return;
}
lasttime = millis(); // ok we have waited DEBOUNCE milliseconds, lets reset the timer
for (index = 0; index < numberButtons; index++) {
justpressed[index] = 0; //when we start, we clear out the "just" indicators
ShortPress[index] = 0;
LongPress[index] = 0;
currentstate[index] = digitalRead(buttons[index]); //read the button
if (currentstate[index] == previousstate[index]) {
if ((pressed[index] == LOW) && (currentstate[index] == LOW)) { // just pressed
justpressed[index] = 1;
Timestart = millis();
}
if ((pressed[index] == HIGH && currentstate[index] == HIGH) && millis() - Timestart < Timelapse) {
justpressed[index] = 0;
ShortPress[index] = 1; // just released
}
else if ((pressed[index] == HIGH && currentstate[index] == HIGH) && millis() - Timestart >= Timelapse) {
justpressed[index] = 0;
LongPress[index] = 1; // just released
}
pressed[index] = !currentstate[index]; //remember, digital HIGH means NOT pressed
}
previousstate[index] = currentstate[index]; //keep a running tally of the buttons
}
}
//void OnConnected() {
// digitalWrite(LED_BUILTIN, HIGH);
//}
//
//void OnDisconnected() {
// digitalWrite(LED_BUILTIN, LOW);
//}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi guys, There is still very little information about these ESP32 S3 boards. I got one to test and I think I can confirm this library is working with the I have. Here is the sketch I used to test it.
Button on pin 4 and GND. When pressed it should send Program Change and Control Change messages, as well as toggle the LED.
Receiving Program Change 10 on any channel will turn the LED ON.
Receiving Program Change 20 on any channel will turn the LED OFF.
This is an example of how we would use basic midi in and out in real life when building midi controllers. Some examples do not show that.
I hope this helps.
To the project owner. If you want I could post a couple more real life examples ;)
Thanks for this amazing library.
All reactions