# MIDI controller with Arduino UNO

**URL:** <https://forum.arduino.cc/t/midi-controller-with-arduino-uno/1115242>\
**Category:** Programming\
**Created:** [April 14, 2023, 5:19pm UTC](https://forum.arduino.cc/t/midi-controller-with-arduino-uno/1115242 "2023-04-14T17:19:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![willtcs](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/willtcs/32/781556_2.png) [@willtcs](https://forum.arduino.cc/u/willtcs)\
**Post date:** [April 14, 2023, 5:19pm UTC](https://forum.arduino.cc/t/midi-controller-with-arduino-uno/1115242/1 "2023-04-14T17:19:13Z")

</div>

I try to make a MIDI controller and use Arduino UNO, with 3 Arcade quality 24mm Push buttons, 3 pots and 2 slider. But it got some error and pop out when use pots or slider While use hairless MIDI. Is the circuit problem or code ? I use Ableton to Mapping the button/pots/slider but no response and sound.

```cpp
#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();

const int buttonPins[] = {2, 3, 4}; 
byte buttonState[3] = {0, 0, 0}; 
const int buttonPitches[] = {36, 37, 38}; 

const int sliderPins[] = {A4, A5}; 
int sliderValues[2] = {0, 0}; 

const int knobPins[] = {A0, A1, A2}; 
int knobValues[3] = {0, 0, 0}; 

void setup() {
  MIDI.begin(); 
 
  for (int i = 0; i < 3; i++) {
    pinMode(buttonPins[i], INPUT_PULLUP);
  }

  
  for (int i = 0; i < 2; i++) {
    pinMode(sliderPins[i], INPUT);
  }

  
  for (int i = 0; i < 3; i++) {
    pinMode(knobPins[i], INPUT);
  }
}

void loop() {
 
  for (int i = 0; i < 3; i++) {
    byte tempRead = digitalRead(buttonPins[i]); 
    if (tempRead != buttonState[i]) {
      buttonState[i] = tempRead; 
      int note = buttonPitches[i]; 
      if ((buttonState[i] == LOW)) {
        MIDI.sendNoteOn(note, 127, 1); 
      } else { 
        MIDI.sendNoteOff(note, 0, 1);
      }
    }
  }

  
  for (int i = 0; i < 2; i++) {
    int value = analogRead(sliderPins[i]); 
    if (abs(value - sliderValues[i]) > 2) { 
      sliderValues[i] = value; 
      int controller = 16 + i;
      int data = map(value, 0, 1023, 0, 127);
      MIDI.sendControlChange(controller, data, 1); 
    }
  }

 
  for (int i = 0; i < 3; i++) {
    int value = analogRead(knobPins[i]);
    if (abs(value - knobValues[i]) > 2) { 
      knobValues[i] = value;
      int controller = i;
      int data = map(value, 0, 1023, 0, 127);       
      MIDI.sendControlChange(controller, data, 1); 
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![PieterP](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@PieterP](https://forum.arduino.cc/u/PieterP)\
**Post date:** [April 14, 2023, 5:40pm UTC](https://forum.arduino.cc/t/midi-controller-with-arduino-uno/1115242/2 "2023-04-14T17:40:27Z")

</div>

Check the baud rate in Hairless. Set it to (at least) 115200, and add `Serial.begin(115200)` at the end of your `setup()` function to override the MIDI library's default rate of 31250 baud.

---

<div class="post-metadata">

**Author:** ![willtcs](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/willtcs/32/781556_2.png) [@willtcs](https://forum.arduino.cc/u/willtcs)\
**Post date:** [April 14, 2023, 5:56pm UTC](https://forum.arduino.cc/t/midi-controller-with-arduino-uno/1115242/3 "2023-04-14T17:56:30Z")

</div>

I added Serial.begin(115200) to my code and set the Baud rate to 115200. It's no error but no response when push buttons or pots or slider. what wrong?

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [October 11, 2023, 5:56pm UTC](https://forum.arduino.cc/t/midi-controller-with-arduino-uno/1115242/4 "2023-10-11T17:56:39Z")

</div>

Closed on October 11, 2023, 5:56pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
