I want to be able to have the code adjust to whatever hexadecimal value comes in from the GUI. The 4th value of the byte is what needs to change.
The GUI sends a string of numerous characters that dictate the code, and I have substrings to pull them apart. Most of the string gets convert to integers which is straight forward, but this aspect needs to be able to replace the above "7F"
Amp1=data.substring(8,10);
So if Amp1 reads "2D", how can I update the byte FESA to become
I want the 0x7F to be a "variable" byte, i.e its value is dependent on what comes in from the GUI.
I have a large String (captial S) come in from the GUI that is constructed by a variety of user inputs, and I break it into numerous substrings. Below is the first bit of code, where it reads the String from the GUI and breaks it apart and converts the data into its appropriate use.
This last part is what is wrong (clearly). I would like a way to take the Amp Strings, which are two digit Hex values, and covert to the proper input for a byte with a leading 0, so that as I change the value of Amp on the GUI, it will update on the code and subsequently the serial communication.
I actually found a work around as Visual Studios does have a Hex to Dec function, so i convert the byte from Hex to Dec before it gets sent to the Arduino, and the byte[4] accepts a dec variable as an input, so I don't need to worry about the 0x with Hex. So i got it to work
I can just change the String.substring(a,b) to pull out the appropriate 3 digit from the String, and then use to.Int() and byte() to change type. I have if statements in the GUI to always make sure it's 3 digits