arduinosoftware-serial

Arduino send ascii chars without carriage return


I am working with a Ciseco srf module trying to send "+++" from an arduino nano. My code is

bool b =false;
void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Serial.write('+');// Ihave tried Serial.write("+++")
  Serial.write('+');// but this sends "+++<CR>" :(
  Serial.write('+');
}
void loop() {
  String content = "";
  char character;
  if(!b)
  {

    //Serial.print("sent");
    b = true;
  }

  while(Serial.available()) {
      character = Serial.read();
      content.concat(character);
  }

  if (content != "") { 
    Serial.println(content);
  }
}

The problem is Arduino seems to send a Carriage Return <CR> on Serial.write("+++") or other combination. Can someone help me turn off the Carriage Return on Arduino and be strict to program serial communication?


Solution

  • According to arduino manual http://www.arduino.cc/en/Serial/Write use serial.write(0x2B) three times to send the '+' character to the SRF module. or you can fill a buffer with those 3 characters and send them with serial.write(buffer,len).