Page 1 of 1

serial communication

Posted: Tue Dec 11, 2012 2:10 pm
by deba168
The result I got is :
49
10
by pressing 1 on key board



void setup() {
Serial.begin(9600);
}

void loop()
{


if (Serial.available() > 0) {
int val= Serial.read();
Serial.println(val);
}
}

Re: serial communication

Posted: Tue Dec 11, 2012 2:29 pm
by abhimanyu
The code seems to be fine.
When you press any key on the KeyBoard, its ASCII character is sent to the Serial Monitor.
Arduino's Serial Monitor has four different choices to display results:
No Line Ending
New Line (NL)
Carriage Return (CR)
Both NL and CR

The additional '10' is for New Line. Similarly, '13' is for Carriage Return. If you do not want any additional character to be displayed, select No Line Ending.

Hope that clarifies your Output.

Re: serial communication

Posted: Fri Dec 14, 2012 4:50 pm
by deba168
thank you...