How receieving values more than 255 by Arduino uno

Thread Starter

youcef hassan

Joined Dec 9, 2016
38
Hello, I have a problem when I am sending values from processing to the Arduino , I can't read the values more than 255, I used the serial port, thanks
 

be80be

Joined Jul 5, 2008
2,072
The arduino just does not do serial write you sending text not bit's and it's a pain if you don't no that your really getting.
You have to do serial.write
First picture i sent 1234
before.png
Second picture show how it comes out
49 is a 1 50 is a 2 51 is 3 and 52 is a 4 an the 10 is new line
after.png
 

be80be

Joined Jul 5, 2008
2,072
Really need to see the arduino code.
But the plain write can only handle 0 to 255 anything bigger you have break it up into bytes. 1-2-3-4
then put it back to 1234 or 1.234
 

ericgibbs

Joined Jan 29, 2010
18,849
hi be80,
Another method often used for numeric data only, is to use packed BCD.
High Nibble 1st digit and Low Nibble 2nd digit.
This format can be sent by 8Bit RS232.
E
 

MrChips

Joined Oct 2, 2009
30,807
Serial communications via UART, RS-232, RS-485, etc. is one byte (8 bits) at a time.
There is nothing to stop you from sending multiple bytes in the form of a packet of n bytes. How you encapsulate the packet is entirely up to you.
 

be80be

Joined Jul 5, 2008
2,072
MrChips that is true but the arduino serial works great at sending whatever you want but you got understand how it sends the bytes.
It don't send what most people think.
Say you send 0x07 Dec 7 you'll think you'll get 7 nope you sent 55 you see it on the monitor as 7 you think all is good and it's not
Now to send plain bytes you got use write and send then out one at a time print formats them and the monitor hides that from you.
I run into this a bit back playing with the esp8266. Lot's of stuff about using print.
This is really good on how to send what the op wants to show up.
http://forum.arduino.cc/index.php?topic=396450.0
 

WBahn

Joined Mar 31, 2012
30,058
At some point your code is sending ASCII (the character '7' is ASCII code 55).

This has the advantage in that you can more easily monitor what is going across the link. But you have to encode and decode it at the endpoints and it is bandwidth inefficient. Still, if you can tolerate the bandwidth and processing hits, it has a LOT of advantages.
 
Top