Not in scope error in 8266

I am trying to compile this code and it gives not in scope error. can somebody help pls, thanks
exit status 1
'dot' was not declared in this scope




#define led 12
#define led 14
#define led 16
char input;// to save the input
void setup () {
  pinMode(12, OUTPUT);
  pinMode(14, OUTPUT);
  pinMode(16, OUTPUT);
  Serial.begin(115200);//for the connect with the board
}

void loop () {
  if (Serial.available()) {
    input = Serial.read();//read the input

    if (input == 'a' || input == 'a') {
      lA(); //if the input is a or A go to function lA
    }

    //  if (input == ' ') {Space();}//the space
    Serial.println (input);//print the latter saved in the input var

  }
}
//functions for the letters and the numbers
void lA () {
  dot(); dash(); {
    dot();  //letterpri in morse code!
    shortspace();
  }

  //void space () {delay (1200);}//space between words
  void dot () {
    digitalWrite(led12, HIGH);  //the dot this code make the led on for 300 than off for 300
    delay (300);
    digitalWrite(12, LOW);
    delay (300);
  }
  void dash () {
    digitalWriteled14, HIGH);  //the dash this code make the led on for 900 than off for 300
    delay (900);
    digitalWrite(l4, LOW);
    delay (300);
  }
  void dot1 () {
    digitalWrite(led16); //space between letters
  }

Count the braces in your lA function.

Your problem has nothing to do with Installation and Troubleshooting (see About the Installation & Troubleshooting category) and has therefore been moved to a more suitable location on the forum.

Oops

thank you very much

I corrected it thanks

If you can't figure out the first error, start looking at all of the other errors and warnings. The first error might be a symptom of one of the others.

When you see a "error: a function-definition is not allowed here before '{' token" it usually means you have an extra '{' or missing '}' in the function ABOVE that point.

/Users/john/Documents/Arduino/sketch_jan25a/sketch_jan25a.ino:2:0: warning: "led" redefined
 #define led 14
 
/Users/john/Documents/Arduino/sketch_jan25a/sketch_jan25a.ino:1:0: note: this is the location of the previous definition
 #define led 12
 
/Users/john/Documents/Arduino/sketch_jan25a/sketch_jan25a.ino:3:0: warning: "led" redefined
 #define led 16
 
/Users/john/Documents/Arduino/sketch_jan25a/sketch_jan25a.ino:2:0: note: this is the location of the previous definition
 #define led 14
 
/Users/john/Documents/Arduino/sketch_jan25a/sketch_jan25a.ino: In function 'void lA()':
sketch_jan25a:32:3: error: 'dot' was not declared in this scope
   dot(); dash();
   ^~~
sketch_jan25a:32:10: error: 'dash' was not declared in this scope
   dot(); dash();
          ^~~~
/Users/john/Documents/Arduino/sketch_jan25a/sketch_jan25a.ino:32:10: note: suggested alternative: 'tanh'
   dot(); dash();
          ^~~~
          tanh
sketch_jan25a:35:5: error: 'shortspace' was not declared in this scope
     shortspace();
     ^~~~~~~~~~
/Users/john/Documents/Arduino/sketch_jan25a/sketch_jan25a.ino:35:5: note: suggested alternative: 'isWhitespace'
     shortspace();
     ^~~~~~~~~~
     isWhitespace
sketch_jan25a:40:3: error: a function-definition is not allowed here before '{' token
   {
   ^
sketch_jan25a:47:3: error: a function-definition is not allowed here before '{' token
   {
   ^
sketch_jan25a:54:3: error: a function-definition is not allowed here before '{' token
   {
   ^
sketch_jan25a:56:3: error: expected '}' at end of input
   }
   ^
exit status 1
'dot' was not declared in this scope

#define led 12
#define led 14
#define led 16

Still whoops

I corrected it but now the led's are not activated.

#define led1 12
#define led2 14
#define led3 16
char input;// to save the input
void setup () {
  pinMode(12, OUTPUT);
  pinMode(14, OUTPUT);
  pinMode(16, OUTPUT);
  Serial.begin(115200);//for the connect with the board
}

void loop () {
  if (Serial.available()) {
    input = Serial.read();//read the input

    if (input == 'pei' || input == 'pri') {
      lA(); //if the input is a or A go to function lA
    }

    //  if (input == ' ') {Space();}//the space
    Serial.println (input);//print the latter saved in the input var

  }
}
//functions for the letters and the numbers
void lA () {
  dot(); 
  dash(); {
    dot();  //letterpri in morse code!    
  }
}
  //void space () {delay (1200);}//space between words
  void dot () {
    digitalWrite(led1, HIGH);  //the dot this code make the led on for 300 than off for 300
    delay (300);
    digitalWrite(led1, LOW);
    delay (300);
  }
  void dash () {
    digitalWrite(led2, HIGH);  //the dash this code make the led on for 900 than off for 300
    delay (900);
    digitalWrite(led2, LOW);
    delay (300);
  }
  void dot1 () {
   digitalWrite(led3, HIGH); //space between letters
   delay (900);
   digitalWrite(led3,LOW);
  }
  

Do you still have the simple LED blink test program you wrote to test that you'd wired the LEDs correctly?

yes

Forget what I said about a test program - your problem is here

Single quotes, single character.

Single quotes were correct - Serial.read returns a single character.

i corrected but nothing happens with led when i input in serial port. the following is the code

#define led1 12
#define led2 14
#define led3 16
char input;// to save the input
void setup () {
  pinMode(12, OUTPUT);
  pinMode(14, OUTPUT);
  pinMode(16, OUTPUT);
  Serial.begin(115200);//for the connect with the board
}

void loop () {
  if (Serial.available()) {
    input = Serial.read();//read the input
  }
    if (input == 'pri' || input == 'pri') {
      lA(); 
    }
    //  if (input == ' ') {Space();}//the space
    //Serial.println (input);}//print the latter saved in the input var

  }

//functions for the letters and the numbers
void lA () {
  dot(); 
  dash(); 
    dot();  //letterpri in morse code!    
  }

  //void space () {delay (1200);}//space between words
  void dot () {
    digitalWrite(led1, HIGH);  //the dot this code make the led on for 300 than off for 300
    delay (300);
    digitalWrite(led1, LOW);
    delay (300);
  }
  void dash () {
    digitalWrite(led2, HIGH);  //the dash this code make the led on for 900 than off for 300
    delay (900);
    digitalWrite(led2, LOW);
    delay (300);
  }
  void dot1 () {
   digitalWrite(led3, HIGH); //space between letters
   delay (900);
   digitalWrite(led3,LOW);
  }
 

Single quotes, single character.
Serial.read returns a single character.

how to code for strings pls

Serial.read returns a single character.
You are trying to compare a single character to a String.
Single characters go in single quotes.

Please stop posting pictures.

See Serial input basics - updated

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.