Ok see this is where Pauls doesn't make sense. In one reply you put that serial.print and serial.write are two different things so if seems odd to the replace print with write. Or is this because I am new and they actually do the same thing. Also I changed a line of code whereby I deleted the word byte from anywhere and the code compiles. So any guidance as to why ?
In one reply you put that serial.print and serial.write are two different things
They are, and I explained why.
so if seems odd to the replace print with write.
What is odd was that print() used to be used to send binary data by using the optional second argument of BYTE. That was not obvious from the name of the function, nor was the BYTE name consistent with the other uses of the second argument, which was, and still is, to define the base (binary, decimal, octal, hex, etc.) to be used when converting the value to a string to be sent.
As a result of the inconsistency, and since there was a perfectly usable method to send binary data already, the BYTE keyword was removed. Now, you must use the correct function to send binary data.
Nothing confusing about it now.
Also I changed a line of code whereby I deleted the word byte from anywhere and the code compiles. So any guidance as to why ?
Reread all the answers you have been given, in light of what is above. If you still don't understand that just removing the BYTE keyword is wrong, I don't think we will be able to convince you.
If you simply run your code, you will see that it doesn't work. Maybe that will convince you.
ok so here i have changed as you have mentioned to do, however if serial.write and serial.print do different things i dont understand why you have said that i need to change it to this:
// Send a MIDI Command with 3 parts
void midiCmd(char cmd, char data1, char data2) {
lastCmd[1] = cmd;
lastCmd[2] = data1;
lastCmd[3] = data2;
Serial.write(cmd);
Serial.write(data1);
Serial.write(data2);
}
// Send a MIDI Command with 2 parts
void midiCmdShort(char cmd, char data1) {
lastCmd[1] = cmd;
lastCmd[2] = data1;
Serial.write(cmd);
Serial.write(data1);
as aposed to this:
// Send a MIDI Command with 3 parts
void midiCmd(char cmd, char data1, char data2) {
lastCmd[1] = cmd;
lastCmd[2] = data1;
lastCmd[3] = data2;
Serial.print(cmd, BYTE);
Serial.print(data1, BYTE);
Serial.print(data2, BYTE);
}
// Send a MIDI Command with 2 parts
void midiCmdShort(char cmd, char data1) {
lastCmd[1] = cmd;
lastCmd[2] = data1;
Serial.print(cmd, BYTE);
Serial.print(data1, BYTE);
So why this new thread?! Aren't you getting help on the other thread? Have you read the sticky thread the forum admin pointed to you yet? Besides, your question is very vague. I read it several times and couldn't understand what the problem is.
basically no i have had little help but have had a few people just being awkward. my original code was -
// Send a MIDI Command with 3 parts
void midiCmd(char cmd, char data1, char data2) {
lastCmd[1] = cmd;
lastCmd[2] = data1;
lastCmd[3] = data2;
Serial.print(cmd, BYTE);
Serial.print(data1, BYTE);
Serial.print(data2, BYTE);
}
// Send a MIDI Command with 2 parts
void midiCmdShort(char cmd, char data1) {
lastCmd[1] = cmd;
lastCmd[2] = data1;
Serial.print(cmd, BYTE);
Serial.print(data1, BYTE);
but was having problems with the sections that have Byte at the end of the line, so put it on here (by the way have not used arduino before or posted anything on here before) and was said that the sections with byte in needed to be changed to serial.write instead of serial.print and discard the Byte
can you help shed some some light here?
this is what i have changed it to -
// Send a MIDI Command with 3 parts
void midiCmd(char cmd, char data1, char data2) {
lastCmd[1] = cmd;
lastCmd[2] = data1;
lastCmd[3] = data2;
Serial.write(cmd);
Serial.write(data1);
Serial.write(data2);
}
// Send a MIDI Command with 2 parts
void midiCmdShort(char cmd, char data1) {
lastCmd[1] = cmd;
lastCmd[2] = data1;
Serial.write(cmd);
Serial.write(data1);
}
I've merged these two threads so that people who have taken the time and effort to reply don't feel they've wasted their time.
I don't think that worked. I've taken the time and effort to explain the Serial.print() and Serial.write() nuances, and explained how to convert the 0022 code to 1.0 code, and why those changes are necessary. I still feel like I wasted my time.
oh i see sorry didnt realise it had gone to a second page, its for a guitar control pedal that is sending out midi signals over a usb interface.
the problem i have is with the sections that have "byte" in them (which is only a couple of lines) if you look back you can see the orignal and what i changed it to, to get a successful compile.
marcjwebb:
oh i see sorry didnt realise it had gone to a second page, its for a guitar control pedal that is sending out midi signals over a usb interface.
the problem i have is with the sections that have "byte" in them (which is only a couple of lines) if you look back you can see the orignal and what i changed it to, to get a successful compile.
So if it successfully compiles now, what is the problem you are having now?