Go Down

Topic: Communicating: UNO R3 to PC via RS232  (Read 199 times) previous topic - next topic

hieberjohn

The circuit uses the MC1488 and MC1489 to interface pin 0 (RX) and pin 1 (TX) the UNO to the PC.

The UNO uses the Serial.read and Serial.write, the PC uses KERMIT terminal program.

The transmission from PC to UNO is correct but echoing the each character back to to the PC it isn't always correct.

For example, the character  "9" becomes ?,p,x, etc. on the PC display  The character are echoed correctly to the IDE Monitor.

Code use in UNO

// echo test
int inByte = 0;   // for incoming serial data
int blinkstate=0;

void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
 
        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:
            inByte = Serial.read();
             Serial.write(inByte);
                       
          if(inByte == 13){
           Serial.write(10);  // line feed

         
        }

  digitalWrite(13, blinkstate);   // turn the LED on off
  delay(250);              // wait for LED to settle
  blinkstate=1-blinkstate
 
 
}
}

PaulS

Quote
The UNO uses the Serial.read and Serial.write, the PC uses KERMIT terminal program.
Why? Serial.write() is for sending binary data. Have you configured KERMIT to deal with binary data?

Code: [Select]
int inByte = 0;   // for incoming serial data
Why? inByte is NOT a byte.

Go Up