I need help.Arduino Uno keyboard (Piano)

Hi everyone, i recently bought the Arduino Uno and it arrived today. i expected there to be a printer cable port but i have the Micro USB. Im trying to make a cutom Midi Keyboard to help with my music but cant seem to figure out whats wrong. I looked everywhere and tried searching but nothing seems to help.

at first i thought it was the code, it seems to work in the IDE but when i go to my DAW or even a Website it cant find the Midi sourse. Is it poosible it could be the connections, If thats a possiblity. Please could you share how it should be done, Thank you ;

#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
void setup() {
MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize MIDI communication
MIDI.turnThruOff(); // Turn off MIDI Thru functionality
// Add any other setup code here
}
void loop() {
noteOn(0, 48, 64);
delay(5000);
noteOff(0, 48, 64);
delay(5000);
}
void noteOn(byte channel, byte pitch, byte velocity) {
MIDI.sendNoteOn(pitch, velocity, channel);
}
void noteOff(byte channel, byte pitch, byte velocity) {
MIDI.sendNoteOff(pitch, velocity, channel);
}

Welcome to the forum

Your topic has been moved to the Programming category of the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Arduino.cc points to this page for the MIDI.h source (click green "code" button, and "download zip" then IDE >> TOOLS >> MANAGE LIBRARIES >> ):

#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
void setup() {
  MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize MIDI communication
  MIDI.turnThruOff(); // Turn off MIDI Thru functionality
  // Add any other setup code here
}
void loop() {
  noteOn(0, 48, 64);
  delay(5000);
  noteOff(0, 48, 64);
  delay(5000);
}
void noteOn(byte channel, byte pitch, byte velocity) {
  MIDI.sendNoteOn(pitch, velocity, channel);
}
void noteOff(byte channel, byte pitch, byte velocity) {
  MIDI.sendNoteOff(pitch, velocity, channel);
}

Was this a real Arduino or a clone, or even a Uno R4? Because a Real Arduino UNO R3 has a normal full-size USB socket.

If it is a Uno then in order for it to be recognised as a MIDI device you need a helper app in your computer that converts serial data into what the system sees as a MIDI device. I use an app called hairless on my Mac but I know this has stopped working because later versions of the OS do not support 32 bit applications anymore only 64 bit ones.

In order for it to be recognised as a MIDI device directly you need to use an Arduino Leonardo or Micro.

1 Like

it says Arduino Uno R3. I bought it from a trusted local site here in South Africa. I thought the same thing but i see that its a Micro USB. Thank you for the response, really appricate it. Ill let you know personally if it works.

If you post a photograph of what you have it would help identify it. This is not the first time a seller in your part of the world has sold a clone as a genuine product.

Hi, I have connected it to Hairless, There is no Midi Out or Midi In, I think it may have to do something with the connections on the acutal bread board. Im wondering if thats maybe something you could assist me with?

No there is nothing you have to do with the board. You need to set the baud rate on hairless to the same baud rate on your machine. Normally this should be a rate as fast as you can.

It is also worth getting an app called midi monitor to see what ports you are creating.

Yes that is a clone not a genuine Arduino. Bang goes that distributor's reputation.

What Mac OS are you running?

I can't see from the photo but you should not be using Pins 0 or 1 to connect to anything else, as that is also the serial data to the Mac.

alright i saw somewhere that i must set it to 9500 but ill go faster.

ohk, Ill get the Midi Monitor thanks

I have Windows 10.

Yeah there isnt anything on the 0 and 1 on the Digital.

Thanks once again.

So i got an App called Midi Veiw and it gives the "No devices found" when i try to search for a Midi. Isaw in Hairless it says i need to update someFTDI driver. I did but it says "Detection was successful but you don’t need any new drivers at this time" im running 22H2 of Windows 11. I also changed my Baud and it hasnt seem to work

Try running this code. It produces random notes.


/* Midi note fire - Mike Cook March 2012
 *
 * ----------------- 
 * send MIDI serial data, automatically for a test
 */ 

// Arduino pin assignments
#define midiChannel (byte)0

// Start of code
void setup() {
 //  Setup serial
   //Serial.begin(31250);    // MIDI speed
   Serial.begin(112500); // hairless speed
}

//********************* MAIN LOOP ***********************************

void loop() {
  int val;
  val = random(20,100);
    noteSend(0x90, val, 127);
    delay(200);
    noteSend(0x80, val, 127);
   delay(800);
    } // end loop function
    
//********************* Functions *********************************** 


//  plays a MIDI note
 void noteSend(char cmd, char data1, char data2) {
  cmd = cmd | char(midiChannel);  // merge channel number
  Serial.write(cmd);
  Serial.write(data1);
  Serial.write(data2);
}

Select the correct port from the drop down menu 'Serial port' on hairless. Note this sends MIDI only it does not receive it.

image

the light is flashing green on the left.

Those error messages mean that there is a baud rate miss match between the rate you are sending and the rate that hairless is set to.


Here is what i have done on the Arduino

image

image

Im a bit confused cause they are both the same

Im also trying to run the code again and its giving me this error.
sketch uses 2254 bytes (6%) of program storage space. Maximum is 32256 bytes.
Global variables use 188 bytes (9%) of dynamic memory, leaving 1860 bytes for local variables. Maximum is 2048 bytes.
avrdude: ser_open(): can't open device "\.\COM3": Access is denied.

Failed uploading: uploading error: exit status 1

No they are not.
The code sets the baud rate at 112500 and you screen dump shows you have it at 128000 these numbers are not the same.

The simple fact that the window in hairless says USB-Serial CH340 shows you that you have a clone not a genuine Arduino. But that should not matter if you get the baud rate correct.

ahh ohk sorry i didnt realise that Bit and Baud are 2 diffrent ones.
Ohk so i changed the buad to 112500.
image
It still shows the Warning but it isnt as frequent as before.

So i have changed everything. Do you think that i plug my code in and the Midi should work?

I think MIDI is not really important. There are many other easier methods of building an Arduino based piano. Such as this: Arduino mini projects | Piano Arduino based mini project

Here is also an eletronic piano without the Arduino:

Yes but it won't sound like a piano, it will sound like a buzzer.

Try it and see but I doubt it. There is still something wrong, maybe your clone has a clock that is not very accurate. There is nothing in the code you originally posted that would actually read the keys, if that is what it is connected to.

The picture you posted of your bread board circuit does not make much sense and there is nothing that shows what is connected beyond the bread board. Those components on the bread board look like diodes, what are they actually?

Where did you get that circuit from?

Would i be able to use it in a DAW?
I like making Remixes so the Piano will have to be a Midi keyboard. i didnt wanna spend tons of Money of the Akai and stuff like that because i just felt the keys are a bit shitty for the money. I really liked my keys on this old keyboard and asked my friend and he told me to do all this stuff. I thought it was going to be plug and play but that doesnt look like the case.