Send raw bytes from Serial monitor?

Greets,

I'm trying to send raw bytes from the serial monitor but keep getting wrong values going through Tx.

Here is the sketch:

byte byteRead;
void setup() { 
  // Turn the Serial Protocol ON
   Serial.begin(31250);  //31250 MIDI BAUD RATE
}
void loop() {
   /* check if data has been sent from the computer: */
   if (Serial.available()) {
   /* read the most recent byte */
     byteRead = Serial.read();
     
     /*Listen for a comma which equals byte code # 44 */
     if(byteRead==44){
       delay(1);
       }else{
       /*ECHO the value that was read, back to the serial port. */
       Serial.write(byteRead);
     }
   }
}

I need to send hex values in raw format, so e.g. if I type in 0xF8 and press send in the serial monitor the Tx pin would output 11111000.

thanks

p.s. I just saw that the Baud rate can't be changed to 31250 in the serial monitor, I guess that's the problem. It overrides the Serial.begin(BAUD RATE).

Think you need to use another serial program.
Perhaps something like Termite

naut:
I need to send hex values in raw format, so e.g. if I type in 0xF8 and press send in the serial monitor the Tx pin would output 11111000.

If you mean that you want to type the characters 0 x F 8 and then press return and have the Arduino receive those 4 characters and interpret them as the decimal value 248 then you could certainly program the Arduino to do that.

But it would NOT be interchangeable with another program that sends the value 248 as a single byte.

...R

naut:
p.s. I just saw that the Baud rate can't be changed to 31250 in the serial monitor, I guess that's the problem. It overrides the Serial.begin(BAUD RATE).

It seems you have your answer :slight_smile:

CrossRoads:
Think you need to use another serial program.
Perhaps something like Termite
Termite: a simple RS232 terminal

I d/l it, changed the baud rate to 31250 but it still not sending raw data as raw bytes. I tried sending f8 , 0xf8, 11111000 and 248 and still get wrong data on my MIDIox midi monitor software.

I guess I need to write a different code.

If you mean that you want to type the characters 0 x F 8 and then press return and have the Arduino receive those 4 characters and interpret them as the decimal value 248 then you could certainly program the Arduino to do that.

It depends from how the terminal program sends data that is input with the keyboard. I can't use the arduino serial monitor anyway, it does not have 31250 baud rate as an option so I'll have to use something else.

For now the only way I can send correct raw data is from within the code, e.g. Serial.write(B11111000); sends a correct 0xF8 byte message. So it's either that Serial.read() does not read or set raw binary data to a variable or the terminal program does not send raw data.

ok, I just tried the terminal window plugin in Atmel Studio 6 an it works! Sends raw data at 31250 baud rate.