Hello everyone. For example,I send a midi message from keyboard likes 144-36-100 the status byte "144" means "note on". The second byte"36" means "middle C". The third byte"100" means velocity. So,can I use string to put the midi message in ? or use substring() to call the message? If string can't do this, what is the better way I can use it ? thanks~
I send a midi message from keyboard
How does the "message" get from the keyboard to the Arduino? The keyboard is not connected to the Arduino, is it?
So,can I use string to put the midi message in ? or use substring() to call the message?
If the "message" is being sent to the Arduino via the serial port, you need to add some sort of start and end of packet markers, so that the Arduino knows when the packet starts and when the end of the packet has arrived. Then, you need to read and store the characters received on the Arduino in an array, starting over when a start of packet marker arrives, until the end of packet marker arrives.
Search for "started && ended" for an example of how to receive and store the characters.
Once you have a complete packet, as an array of characters, NULL terminated, you can use strtok() to parse the string, and atoi() to convert each token to an integer.