Go Down

Topic: serial caracter not expected (Read 354 times) previous topic - next topic

joxevc

First of all, must say that I'm newbie to electronics and Arduino.
I've spent a lot of time findind a solution to my problem.
It must have an easy explanation but I just cant find it.

It's as simple as this....

I write a number in serial port like this

Serial.write(5);

when I monitor serial port I get "f" caracter.....

Any idea????

Thanks in advance!!

PaulS

Quote
It's as simple as this....

I write a number in serial port like this

Serial.write(5);

when I monitor serial port I get "f" caracter.....

Any idea????

You need to explain why you want to use a method that sends binary data (Serial.write()) to talk to a device that expects ASCII data (the Serial Monitor). You could also explain why you are surprised when the results are not what you expect.

BetaDelta

If you want to have a '5' displayed then you need to use Serial.print(5, DEC) to display it as a decimal.
"C++ : Where friends have access to your private members." - Gavin Russell Baker

PaulS

Quote
If you want to have a '5' displayed then you need to use Serial.print

Yes.

Quote
, DEC) to display it as a decimal.

No. The default for integer values is to display the value in base 10. So, the , DEC is not required. If you want to display in base 7 or base 22, then you need to use the second argument to define the base to use.

joxevc

#4
Dec 02, 2012, 12:35 am Last Edit: Dec 02, 2012, 12:37 am by joxevc Reason: 1
Thank you all,

It works fine now
Serial.write((byte)5);

I was using diferent baudrate speed in code and serial monitor...

Go Up