Go Down

Topic: Sending Carriage Return [ENTER] to the Serial Port (Read 5372 times) previous topic - next topic

chiques

Hello,
I need to send a couple of characters to my device to get it going. I'm able to get the characters sent but I'm having trouble getting the 'carriage return' to be sent.

Referring to http://arduino.cc/en/Reference/ASCIIchart

Code: [Select]


     int poweron = 111;
     int cr = 13;
     int continuous = 99;
     Serial.write(poweron); // Turn  on 'o'
     delay(1000);
     Serial.write(cr);  // Carriage Return
     delay(1000);
     Serial.write(continuous);  // Activate Continuous Function 'c'
     delay(1000);
     Serial.write(cr); //  Carriage Return
     delay(1000);


If I press ENTER on my keyboard the two characters are sent to the serial terminal.

:smiley-roll-blue:

Thanks for any help

Coding Badly

Code: [Select]
     Serial.write( 'o' ); // Turn  on 'o'
     delay(1000);
     Serial.write( '\r' );  // Carriage Return
     delay(1000);
     Serial.write( 'c' );  // Activate Continuous Function 'c'
     delay(1000);
     Serial.write( '\r' ); //  Carriage Return
     delay(1000);

holmes4

Quote
If I press ENTER on my keyboard the two characters are sent to the serial terminal.


The normal line terminator is CR LF (it's a left over from the dark ages).

Mark

chiques


Code: [Select]
    Serial.write( 'o' ); // Turn  on 'o'
    delay(1000);
    Serial.write( '\r' );  // Carriage Return
    delay(1000);
    Serial.write( 'c' );  // Activate Continuous Function 'c'
    delay(1000);
    Serial.write( '\r' ); //  Carriage Return
    delay(1000);



Hmm, still hanging unless I press enter on the keyboard.

Code: [Select]

delay(1000);
     Serial.write( 'o' ); // Turn on 'o'
     delay(1000);
     Serial.write( '\r' );  // Carriage Return
     delay(1000);
     Serial.write( 'c' );  // Activate Continuous Function 'c'
     delay(1000);
     Serial.write( '\r' ); //  Carriage Return
     delay(1000);

PeterH


Hmm, still hanging unless I press enter on the keyboard.


In order to work correctly, which does it need?

  • \n

  • \r

  • \r\n



They're all plausible. From here we can't guess which it needs. If you don't know which it needs, try them all until you find what works.
I only provide help via the forum - please do not contact me for private consultancy.

Go Up