user14119: Hi i have made this code
its so simple its should receive data from the computer and send it back via the serial but the problem is he do not what it is suppose to do
when its run its keep sending -1 to the computer
and if i send something to the arduini  like  55   i receive and answer 53
i have no idea were is the problem in this code
long number = 0;

void setup() {
  Serial.begin(9600);
}
   void loop() {
   number = Serial.read();
   delay(1000);
   Serial.println(number);
}


user313: Serial.read() returns one character from the input. Serial.println will try to convert a variable into ASCII characters, and print that. Your variable, number gets the ASCII code of the first typed character in its first byte. The Serial.println call will interpret that and the next 3 bytes (whatever they happen to be...?) as a value to be printed.
Your problem is in not understanding the conversion of digit strings into values and vice-versa, and of how the Serial.xxx functions work.
You'll need to collect the terminal input character-by-character into an array, then convert it to a numeric value (assuming you're eventually going to do more with it than print it back out). Then you could Serial.println() that (or another) value out to the terminal.

user14060: You need to include DEC as the second argument to the Serial.println() call to get the correct numbers out.  Read up on this here: Arduino Serial Print. 
In other words, make change below: 
Serial.println(number, DEC); // DEC is needed to get the correct values


14119: <p>Hi i have made this code
its so simple its should receive data from the computer and send it back via the serial but the problem is he do not what it is suppose to do
when its run its keep sending -1 to the computer
and if i send something to the arduini  like  55   i receive and answer 53
i have no idea were is the problem in this code</p>

<pre><code>long number = 0;

void setup() {
  Serial.begin(9600);
}
   void loop() {
   number = Serial.read();
   delay(1000);
   Serial.println(number);
}
</code></pre>
 313: <p><code>Serial.read()</code> returns one character from the input. <code>Serial.println</code> will try to convert a variable into ASCII characters, and print that. Your variable, <code>number</code> gets the ASCII code of the first typed character in its first byte. The <code>Serial.println</code> call will interpret that and the next 3 bytes (whatever they happen to be...?) as a value to be printed.</p>

<p>Your problem is in not understanding the conversion of digit strings into values and vice-versa, and of how the Serial.xxx functions work.</p>

<p>You'll need to collect the terminal input character-by-character into an array, then convert it to a numeric value (assuming you're eventually going to do more with it than print it back out). Then you could <code>Serial.println()</code> that (or another) value out to the terminal.</p>
 14060: <p>You need to include <code>DEC</code> as the second argument to the <code>Serial.println()</code> call to get the correct numbers out.  Read up on this here: <a href="https://www.arduino.cc/en/Serial/Print" rel="nofollow">Arduino Serial Print</a>. </p>

<p>In other words, make change below: </p>

<pre><code>Serial.println(number, DEC); // DEC is needed to get the correct values
</code></pre>
