Incoming serial data return ASCII no. ; Need to return same typed no.

Status
Not open for further replies.
I am working on the program in which the input typed in the serial monitor should be echoed back.
Whenever I am entering any number in serial no I am getting the ASCII number back.
Is there any function in which we can return the same value back which has been written in the serial monitor.

Code:
int incomingByte = 0; // for incoming serial data

void setup() {
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}

void loop() {
  // send data only when you receive data:
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // say what you got:
    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);
  }
}
 
Status
Not open for further replies.
Back
Top