Song
Song

Reputation: 1

Arduino Serial.println

#include <SoftwareSerial.h>

int blueTx = 2;
int blueRx = 3;

SoftwareSerial mySerial(blueTx, blueRx);

String myString = "";

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);


}

void loop() {
  while (mySerial.available()){
    char myChar = (char)mySerial.read();
    myString += myChar;
    delay(5);
}

  if (!myString.equals("")){
    Serial.println("input value : " + myString);    //this is error area 
    myString = "";
  }
}

I can't find this is error why I know "Serial" not should use hader file why Serial.println has error I typed Serial.begin....

Upvotes: 0

Views: 302

Answers (1)

ObliteratedJillo
ObliteratedJillo

Reputation: 5166

The last few codes needs correction as detailed below:

if (!myString.equals("")){
   String str = "Input value : ";
   str += myString;
   Serial.println(str);    
   myString = "";
}

Upvotes: 2

Related Questions