error: 'lcd' was not declared in this scope - When TAB is used

Hello everybody,

I am using an Arduino/Genuino Uno VID: 2341 and the IDE with the version nbr. 1.8.5.

I am trying to split my code in tabs. I have used the “IR_Receiver_Module.ino” (my main file) as a starting point. (Came with the starting kit on a CD-ROM)
Just for testing purposes I have added the LCD-library by #include <LiquidCrystal.h> into the main file. I now can use the functions of the display in the R_Receiver_Module.ino program.

Then I set up a TAB (by using the little down pointing triangle) and I am using a little function there. Nothing else. Here is the compete code of the tab

*** Start of Copy TAB***

#include <LiquidCrystal.h>

void warten()
{
Serial.println("Warten() ");
lcd.print(“Warten() !”);
}

*** End of Copy ***

*** Start of Copy Main file ***
In one routine I call Warten()

void Warten();
*
*

In the main file, I have already included “LiquidCrystal.h”. I have tried the tab code with and without including LiquidCrystal.h, but upon compiling it I receive only this error message: test:7: error: ‘lcd’ was not declared in this scope.
If I blank the line lcd.print(“Warten() !”); out, The code runs through compilation without any complaints.

Does anybody have an idea what I am doing wrong there?

Thank you very much and enjoy New Year’s Eve.

Greetings
Peter

Where is the lcd instance constructor? Something like:

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

It would be better if you post all the code (in code tags, please).

Hello Ground Fungus,

you were pointing in the right direction.
I have set the LiquidCrystal lcd(7,8,9,10,11,12) declaration global (before it was in the setup routine. Now it is global, and compilation works without error.

But I am not fully there where I want to be: The lcd.print in TAB command doesn't bring any result on the display. Do you have any idea?
Thanks a lot for your help!
Peter

The mainfile:#
#include "IRremote.h"
#include "LiquidCrystal.h"
LiquidCrystal lcd(7,8,9,10,11,12);
int receiver = 5; // Signal Pin of IR receiver to Arduino Digital Pin 11

/-----( Declare objects )-----/
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'

/-----( Function )-----/
void translateIR() // takes action based on IR code received

// describing Remote IR codes

{

switch(results.value)

{
case 0xFFA25D: Serial.println("POWER");
void warten();
break;
case 0xFFE21D: Serial.println("FUNC/STOP"); break;

 switch (results.value)
   {
      case 0xFFA25D: Serial.println("POWER");
         void warten();  //  THIS IS A FUNCTION DECLARATION INSIDE OF A FUNCTION (not allowed),
         warten();        // THIS IS A FUNCTION CALL

I am surprised that the code compiles. You have a function declaration inside of the translateIR function definition. That is illegal.

That is not all of the code. It is a snippet. It will not compile. There are no setup() nor loop() functions, We can better help you if you post all the code, including the code in the tab all in one post, IN CODE TAGS, so we know what we are working with. Help us to help you or you're on your own.

Read the how to use this forum-please read sticky to see how to post code and get the most from the forum.

Hello GroundFungus,

Another luckyStrike from you. The function was declared twice. The compiler didn't bother. I have corrected it, and it works now.
Thanks a lot for your comment.
I did not put all my code in, because I didn't want to bother the reader with to much code.
Next time I will do better.
Have a nice New Years's eve and enjoy 2019!
Greetings from Wiesbaden, Germany
Peter