I’m working on a project that is primarily on the Arduino, but uses a Processing app to configure the Arduino. I’ve devised a simple protocol to transfer data between the Arduino and the computer. There are 3 main parts to the protocol.
1: the computer sends data to the Arduino to request the current config data.
2: the Arduino replies with the current config data.
3: the computer can send new config data back to the Arduino
The problem I’m having is that none of this is really working. When the Arduino replies with the current config, the values the computer receives are not the same ones that are actually in the Arduino, and actually seem to be completely random. When the computer sends new config data to the Arduino, the Arduino doesn’t seem to receive the proper data, and can’t parse it into the relevant variables. Aditionally, the length of the data “packets” the computer sees coming from the Arduino seem to be completely random, despite having fixed-length arrays in every serial.write() line.
In addition to all of this, the buttons attached to the arduino, each of which sends a different midi command, send commands that don’t make any sense, and shouldn’t even be possible given my code. Bytes of the command which are pulled from a single variable for all 6 buttons are different depending on which button is pushed. That shouldn’t even be possible.
There’s so much wrong here I don’t even know where to start. Every time I fix one thing, something else breaks.
The code is a bit long to put in this post, so I’ve attached the files.
Archive.zip (14.3 KB)