Pages: [1]   Go Down
Author Topic: serial caracter not expected  (Read 322 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!!
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Keynsham, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 224
I like for loops and walks on the beach,
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you want to have a '5' displayed then you need to use Serial.print(5, DEC) to display it as a decimal.
Logged

"C++ : Where friends have access to your private members." - Gavin Russell Baker

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you all,

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

I was using diferent baudrate speed in code and serial monitor...
« Last Edit: December 01, 2012, 06:37:41 pm by joxevc » Logged

Pages: [1]   Go Up
Jump to: