tttapa / Control-Surface

Arduino library for creating MIDI controllers and other MIDI devices.
GNU General Public License v3.0
1.25k stars 139 forks source link

Esp32 pin layout. #206

Closed bmarshall91 closed 4 years ago

bmarshall91 commented 4 years ago

I'm trying to make a 4 footswitch BLE Midi footswitch to send program changes. Just having a problem working out how the pins and inputs in the examples (specifically the program change example) relate to the pin out diagram for the ESP32 Dev kit 1. I know it's probably simple but I'm struggling to find the answer.

Thanks in advance

tttapa commented 4 years ago

The Control Surface library uses the standard Arduino pin numbers (i.e. the ones you use with digitalWrite etc.). These should be listed on the pinout diagram for your specific board. On some diagrams, they may be prefixed with GPIO (general purpose input/output).

For example, if you have a button connected to the pin labeled GPIO5, you could use the following in your code:

// Instantiate a PCButton that reads the input from a push button and sends out
// a MIDI Program Change message when it's pressed.
PCButton pcBtn = {
  5,                                 // pin
  {MIDI_PC::Steel_Drums, CHANNEL_1}, // address
};
bmarshall91 commented 4 years ago

Ah simple.

So if I did:

// Instantiate a selector that reads three buttons and controls the program// changerManyButtonsSelector<3> programSelector = { programChanger, {{2, 3, 4}},};

This would be GPIO pins 2, 3 and 4?

Thank you for taking the time to answer a basic problem.

tttapa commented 4 years ago

So if I did:

// Instantiate a selector that reads three buttons and controls the program
// changer
ManyButtonsSelector<3> programSelector = { programChanger, {{2, 3, 4}},};

This would be GPIO pins 2, 3 and 4?

Exactly.