mj1261829
mj1261829

Reputation: 1319

Arduino Error: expected unqualified-id before '['

I am new to Arduino and I get the following Error:

Simple_Display_Text_From_Android:6:5: error: expected unqualified-id before '[' token char[] IncomingText = {}; // for processing and printing incoming text to arudino ^ C:\Users\Muaz Aljarhi\Documents\Arduino\Simple_Display_Text_From_Android\Simple_Display_Text_From_Android.ino: In function 'void loop()': Simple_Display_Text_From_Android:16:3: error: 'IncomingText' was not declared in this scope IncomingText = Serial.read(); //Read the incoming data and store it into variable IncomingText ^ exit status 1 expected unqualified-id before '[' token

Here is the code:

char[] IncomingText = {}; // for processing and printing incoming text to arudino
    
    void setup() {
      // put your setup code here, to run once:
      Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission
    
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
      IncomingText = Serial.read();      //Read the incoming data and store it into variable IncomingText
      Serial.print(IncomingText);        //Print Value of IncomingText in Serial monitor
      Serial.print("\n");        //New line 
    }

How to fix?

Upvotes: 0

Views: 681

Answers (1)

Ali Redha
Ali Redha

Reputation: 335

You need to change the brackets try this code

char[] IncomingText = [] ; // for processing and printing incoming text to arudino
    
    void setup() {
      // put your setup code here, to run once:
      Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission
    
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
      IncomingText = Serial.read();      //Read the incoming data and store it into variable IncomingText
      Serial.print(IncomingText);        //Print Value of IncomingText in Serial monitor
      Serial.print("\n");        //New line 
    }

Upvotes: 1

Related Questions