Pages: [1]   Go Down
Author Topic: Sending Carriage Return [ENTER] to the Serial Port  (Read 4497 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

     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
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
     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);
Logged

Poole, Dorset, UK
Offline Offline
Edison Member
*
Karma: 52
Posts: 2395
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
    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:
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);


* carriage_return_not_working.png (33.08 KB, 410x377 - viewed 243 times.)
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: [1]   Go Up
Jump to: