help needed on bit of code, please, anyone????

here is the line of code : Serial.print(cmd, BYTE);

i just wanted to know that if i take out the word Byte, like this - Serial.print(cmd); will it work the same????

first line from the section of code that is:
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);
}

change

Serial.print(whatever, BYTE);

to

Serial.write(whatever);

Serial.print(whatever) will convert your number to letters representing the number and then print it.

so doing this instead will work fine?? and same for the others with "Byte" too???

Serial.print(cmd);

so doing this instead will work fine?

No. Serial.print() and Serial.write() send data in completely different ways.

byte val = 243;
Serial.print(val);

will send '2', '4', and '3' to the serial port.

Serial.write(val);

will send 243 to the serial port.

ok thats cool, so how would you go about this section with "Byte" in a number of lines:

// 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 how would you go about this section with "Byte" in a number of lines:

Replace them with Serial.write() just like you've been told at least three times now.

It should look like this:
Serial.write(cmd);
Serial.write(data1);
Serial.write(data2);

etc...

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);

here is the code as its original state:

// 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);
}

and i have changed 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);
}

i have changed it as it says "Byte does not name a...." with the version 1.0

so now the one above should work fine and get round the Byte thing????????

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'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.

You may want to start by saying what you are trying to do with this (new) code and what problem you are having.

like i said guys i am new here and stil finding my feet so bare with me i will pick up the forum quick enough.

marcjwebb:
like i said guys i am new here and stil finding my feet so bare with me i will pick up the forum quick enough.

Ok, but that doesn't answer the question of what the issue with the new code is and what you are trying to do

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?