Go Down

Topic: Serial MIDI for drum machine (Read 158 times) previous topic - next topic

montoyamoraga

hi everyone!

i have had success controlling a hardware drum machine with my Arduino Uno, but now with the Arduino Nano 33 BLE Sense it's not working :(

i am using Serial1 for the hardware MIDI connection, and according to the post i found here
https://forum.arduino.cc/index.php?topic=686659.0
maybe the baudrate 31250 neccesary for MIDI is not achievable?

here is my code / comments, thanks so much :)

void setup() {
  Serial.begin(9600);
  Serial1.begin(31250);
}

void loop() {
  // 0x99 is hexadecimal for 153 decimal
  // 153 is note on channel 10
  // 49 is crash cymbal
  // 127 is velocity
  midiCommand(0x99, 49, 127);
  delay(1000);
}

// send 3 byte midi message
void midiCommand(byte cmd, byte data1, byte data2) {

  Serial1.write(cmd);
  Serial1.write(data1);
  Serial1.write(data2);

  Serial.println("beep");
}

and i want to control a hardware MIDI drum machine with it, i am able to do it with

here is my code so far:



i saw on this post some issues about the baudrate
https://forum.arduino.cc/index.php?topic=686659.0

Klaus_K

If you follow the links in the description you will see that your baudrate is not supported by the library code. Using the formula given in the example the baudrate register value should be 0x800000.

Can you try this?
Code: [Select]
Serial1.begin( 9600 );
uint32_t baudrate = 0x800000;
uint32_t *pBaudrate = ( uint32_t * )0x40002524;
*pBaudrate = baudrate;

Note: We use the begin() function to initialize Serial1 but then change the baudrate register "manually".

montoyamoraga

hi klaus thank you so much, now my MIDI is working!!! :)

Go Up