Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

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

  1. #1
    Junior Member
    Join Date
    Sep 2016
    Location
    Mumbai
    Posts
    17

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

    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);
      }
    }

  2. #2
    Senior Member
    Join Date
    May 2017
    Posts
    238
    Code:
    Serial.write(incomingByte);
    Serial.println();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •