Help with error code

I’m getting an exit status 1 “ENCODER” was not declared in this scope error, however, the code for the encoder works on its own withouth the i2c code. Any help is deeply appreciated and thanks

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR    0x3F // <<----- Add your address here.  Find it from I2C Scanner
#define I2C_ADDR    0x3E // <<----- Add your address here.  Find it from I2C Scanner
#include "math.h"
#include "Quadrature.h"
Quadrature quad1(2, 3);
Quadrature quad2(4, 5);
Quadrature quad3(6, 7);




int CodeIn;// used on all serial reads
int KpinNo; 
int Koutpin;
LiquidCrystal_I2C lcd1(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address
LiquidCrystal_I2C lcd2(0x3E, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  
// Specify the 2nd I2C chip address used for 2nd LCD & its connection pins 
// (addr, en,rw,rs,d4,d5,d6,d7,bl,blpol);
String KoldpinStateSTR, KpinStateSTR, Kstringnewstate,Kstringoldstate;

int R;// a variable
int Rold;// the old reading
int Rdif;// the difference since last loop
int R2;// a second test variable
int R3;// a second test variable
int Rold2;// a second loop old reading
int Rdif2; // the second test difference
int Rold3;// a second loop old reading
int Rdif3; // the second test difference

String altit, altitold, vertsp, vertspold, hdgset, hdgsetold, flaps, flapsold, g, gold;
void setup() 
{
  Kstringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111";
  for (int KoutPin = 2; KoutPin < 20; KoutPin++)// Get these pins ready as inputs  
  {
    pinMode(KoutPin, INPUT);
    digitalWrite(KoutPin, HIGH);  
  }
  lcd1.begin(16, 2);
  lcd1.clear();
  lcd1.print(" ");
   lcd2.begin(16, 2);
  lcd2.clear();
  lcd2.print(" ");
 Serial.begin(115200);   
}

void loop() {
  
  {ENCODER();} //Check the Rotary Encoders
  {INPUTS();} //Check the "Inputs" section
   
  if (Serial.available()) {
    CodeIn = getChar();
  
    if (CodeIn == '<') {LESSTHAN();}// The first identifier is "<"
    if (CodeIn == '?') {QUESTION();}// The first identifier is "?"
    if (CodeIn == '/') {SLASH();}// The first identifier is "/" (Annunciators)
  }//end of serial read bit
}//end of void loop

char getChar()// Get a character from the serial buffer
{
  while(Serial.available() == 0);// wait for data
  return((char)Serial.read());// Thanks Doug
}

void LESSTHAN(){
  CodeIn = getChar(); // Get the second identifier
  switch(CodeIn) {// Now lets find what to do with it
   case 'D': // found AP altitude setting
      delay (11);
      altit = "";
      altit += getChar();
      altit += getChar();
      altit += getChar();
      altit += getChar();
      altit += getChar();
      if (altit != altitold){
        lcd1.setCursor(0, 0);
      lcd1.print("Altitude        ");
     lcd1.setCursor(0, 0);
      lcd1.print("Altitude " + altit);
      }        
    break;
  
   case 'P': // found AP heading setting
      delay (11);
      hdgset = "";
      hdgset += getChar();
      hdgset += getChar();
      hdgset += getChar();
      if (hdgset != hdgsetold){
        lcd1.setCursor(0, 1);
      lcd1.print("IAS        ");
     lcd1.setCursor(0, 1);
      lcd1.print("IAS " + hdgset);
       }       
   break;
    case 'G': // found AP heading setting
      delay (11);
      flaps = "";
      flaps += getChar();
      flaps += getChar();
      flaps += getChar();
      if (flaps != flapsold){
        lcd2.setCursor(0, 0);
      lcd2.print("Fp        ");
     lcd2.setCursor(0, 0);
      lcd2.print("Fp " + flaps);
       }       
   break;
    case 'L': // found AP heading setting
      delay (11);
      vertsp = "";
       vertsp += getChar();
       vertsp += getChar();
       vertsp += getChar();
       vertsp += getChar();
       vertsp += getChar();
       vertsp += getChar();
      if ( vertsp !=  vertspold){
        lcd2.setCursor(0, 1);
      lcd2.print("VS        ");
     lcd2.setCursor(0, 1);
      lcd2.print("VS " +  vertsp);
       }       
   break;
   case 'A': // found AP heading setting
      delay (11);
      g = "";
       g += getChar();
       g += getChar();
       g += getChar();
       
      if ( g !=  gold){
        lcd2.setCursor(0, 10);
      lcd2.print(" N        ");
     lcd2.setCursor(0, 10);
      lcd2.print("N " +  10);
       }       
   break;
  
    }//end of case switch
  }// end of void equals


void QUESTION(){    // The first identifier was "?"
//do something
}// end of question

void SLASH(){    // The first identifier was "/" (Annunciator)
  //Do something
}

void INPUTS() 
{
  Kstringnewstate = "";
  for (int KpinNo = 2; KpinNo < 20; KpinNo++){// Pins 22 thru to 69 are all inputs
    KpinStateSTR = String(digitalRead(KpinNo)); 
    KoldpinStateSTR = String(Kstringoldstate.charAt(KpinNo - 22));//the 22 needs to be the same as the 22 in the "for" loop line.
    if (KpinStateSTR != KoldpinStateSTR)
    {
if (KpinNo != 13){ // avoid using pin 13 as an input unless you know the tricks. 
       if (KpinNo == 2 && KpinStateSTR == "0"){Serial.println ("Y03");}
   if (KpinNo == 2 && KpinStateSTR == "1"){Serial.println ("Y031");}
   
      // add more direct inputs here but raise the pinNo (35) in the above live and the line below.
      //now the "keys" bit. Note the pinNo 35 in the line above and the line below.
      if (KpinNo > 35){
      Serial.print ("D"); 
      if (KpinNo < 10) Serial.print ("0");
      Serial.print (KpinNo);
      Serial.println (KpinStateSTR);
      }//end of "keys" bit
    }//end of yes it's different
    Kstringnewstate += KpinStateSTR;
  }//end of "for" loop
  Kstringoldstate = Kstringnewstate;
  }
void ENCODER()
{
R =(quad1.position()/2); //The /2 is to suit the encoder(See my website)
  if (R != Rold) { // checks to see if it different
    (Rdif = (R-Rold));// finds out the difference
   if (Rdif == 1) Serial.println ("Y0310000");//Com1 Mhz down
   if (Rdif == -1) Serial.println ("Y0350000"); //Com1 Mhz up
   Rold = R; // overwrites the old reading with the new one.
  } 
  R2 =(quad2.position());
  if (R2 != Rold2) {
    (Rdif2 = (R2-Rold2));
    if (Rdif2 == 1) Serial.println ("Y0410000"); // Com1 Khz down
    if (Rdif2 == -1) Serial.println ("Y0450000");//Com1 Khz up
    Rold2 = R2;
  }
  R3 =(quad3.position());
  if (R3 != Rold3) {
    (Rdif3 = (R3-Rold3));
    if (Rdif3 == 1) Serial.println ("Y0410000"); // VOR bug down
    if (Rdif3 == -1) Serial.println ("Y0450000"); //VOR bug up
    Rold3 = R3;
  }
}

Do a Tools > Auto Format on your code and then take a close look at the indentation. Do you see the problem now?

If you're using the Arduino Web Editor then you will not have access to the useful Auto Format tool and I recommend that you use the standard IDE instead.

pert: Do a Tools > Auto Format on your code and then take a close look at the indentation. Do you see the problem now?

If you're using the Arduino Web Editor then you will not have access to the useful Auto Format tool and I recommend that you use the standard IDE instead.

I auto-formatted the code (thanks for teaching me this new tool btw) and this is the new code, however, I am still getting the same error code.

Auto Format won't ever fix bugs in your code. However it's a very useful troubleshooting tool. If you have a mysterious error do an Auto Format and then take a close look at the indentation. If the indentation is not as expected that gives you a good clue where the problem is.

Hint: The start of a function definition should never be indented.

Please pick a format for indentation and brackets and stick with it through the code. You will do yourself a favor. I am not partial to the autoformat method though one of the most popular. I use a formatting from a software company from 25 years ago that forces alignment of the curly brackets and by merely noting the horizontal cursor position allows instant verification of matching brackets. This of course is from the edit and DOS 4 days, way before Windows and fancy features such as this.

hint*hint

If you are in the standard editor and click next to a close curly bracket } it will show you what (it thinks) is the matching opening bracket { by outlining it in a square box.

pert: Auto Format won't ever fix bugs in your code. However it's a very useful troubleshooting tool. If you have a mysterious error do an Auto Format and then take a close look at the indentation. If the indentation is not as expected that gives you a good clue where the problem is.

Hint: The start of a function definition should never be indented.

adwsystems: Please pick a format for indentation and brackets and stick with it through the code. You will do yourself a favor. I am not partial to the autoformat method though one of the most popular. I use a formatting from a software company from 25 years ago that forces alignment of the curly brackets and by merely noting the horizontal cursor position allows instant verification of matching brackets. This of course is from the edit and DOS 4 days, way before Windows and fancy features such as this.

hint*hint

If you are in the standard editor and click next to a close curly bracket } it will show you what (it thinks) is the matching opening bracket { by outlining it in a square box.

Im really lost to be honest, I have clicked next to the brackets and the closing bracket is where I need it. I also changed the indentations and played around with them as shown on this page https://codehs.gitbooks.io/introcs/content/Programming-with-Karel/how-to-indent-your-code.html but I still get the same error, Im really sorry I dont seem to be getting the point.

Show us the code.

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR    0x3F // <<----- Add your address here.  Find it from I2C Scanner
#define I2C_ADDR    0x3E // <<----- Add your address here.  Find it from I2C Scanner
#include "math.h"
#include "Quadrature.h"
Quadrature quad1(2, 3);
Quadrature quad2(4, 5);
Quadrature quad3(6, 7);

/*
    This code is in the public domain
    For use with "Link2fs_Multi"
    Jimspage.co.nz
    My thanks to the Guys that gave me snippets of code.
    This is designed to be used with the Mega although it can be converted to use on the Uno.

    This is just a "demo" of switching the sim's lights on and off and showing the
    Autopilot target Altitude and the Vert.speed on a common 16x2 LCD.
    It also shows the Heading and Flaps settings.

    The LCD is connected to pins 2,3,4,5,6 and 7

    The light switchs all use simconnect.(not "keys") but the remaining
    pin's above pin 35 can be used for switchs using "Keys" in my program.
    Some planes are not set up for individual switchings so just fiddle and
    watch the extraction '<f' while clicking with your mouse or testing with
    the "Test" button ,,  most are OK tho.
    On some planes it is even upside-down on some switchs.
    It must have been a Monday morning job at M$ !!!
    The 10 '1's or '0's being sent equate to,,,, (in order, left to right) ,,,
    Nav, Beacon, Landing, Taxi, Strobe, Panel, Recognition, Wing, Logo, Cabin.

    These lights codes suit the use of TOGGLE switchs as are in the planes for this purpose.
    The other switchs are push button type. (Autopilot stuff, increase or decrease the
    target Altitude and Vert speed.)
    ==========================================
    YOU NEED TO TICK THE FOLLOWING IN THE "Multi"
    =b  AP Autopilot Alt set
    =c  AP Autopilot Vert sp set
    =d  AP heading set
    <G  Flaps position
    ==========================================
*/


int CodeIn;// used on all serial reads
int KpinNo;
int Koutpin;
LiquidCrystal_I2C lcd1(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address
LiquidCrystal_I2C lcd2(0x3E, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
// Specify the 2nd I2C chip address used for 2nd LCD & its connection pins
// (addr, en,rw,rs,d4,d5,d6,d7,bl,blpol);
String KoldpinStateSTR, KpinStateSTR, Kstringnewstate, Kstringoldstate;

int R;// a variable
int Rold;// the old reading
int Rdif;// the difference since last loop
int R2;// a second test variable
int R3;// a second test variable
int Rold2;// a second loop old reading
int Rdif2; // the second test difference
int Rold3;// a second loop old reading
int Rdif3; // the second test difference

String altit, altitold, vertsp, vertspold, hdgset, hdgsetold, flaps, flapsold, g, gold;
void setup()
{
  Kstringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111";
  for (int KoutPin = 2; KoutPin < 20; KoutPin++)// Get these pins ready as inputs
  {
    pinMode(KoutPin, INPUT);
    digitalWrite(KoutPin, HIGH);
  }
  lcd1.begin(16, 2);
  lcd1.clear();
  lcd1.print(" ");
  lcd2.begin(16, 2);
  lcd2.clear();
  lcd2.print(" ");
  Serial.begin(115200);
}

void loop() {
  

  {ENCODER();} //Check the Rotary Encoders
  {INPUTS();} //Check the Rotary Encoders
  if (Serial.available()) {
    CodeIn = getChar();

    if (CodeIn == '<') {
      LESSTHAN(); // The first identifier is "<"
    }
    if (CodeIn == '?') {
      QUESTION(); // The first identifier is "?"
    }
    if (CodeIn == '/') {
      SLASH(); // The first identifier is "/" (Annunciators)
    }
  }//end of serial read bit
}//end of void loop

char getChar()// Get a character from the serial buffer
{
  while (Serial.available() == 0); // wait for data
  return ((char)Serial.read()); // Thanks Doug
}

void LESSTHAN() {
  CodeIn = getChar(); // Get the second identifier
  switch (CodeIn) { // Now lets find what to do with it
    case 'D': // found AP altitude setting
      delay (11);
      altit = "";
      altit += getChar();
      altit += getChar();
      altit += getChar();
      altit += getChar();
      altit += getChar();
      if (altit != altitold) {
        lcd1.setCursor(0, 0);
        lcd1.print("Altitude        ");
        lcd1.setCursor(0, 0);
        lcd1.print("Altitude " + altit);
      }
      break;

    case 'P': // found AP heading setting
      delay (11);
      hdgset = "";
      hdgset += getChar();
      hdgset += getChar();
      hdgset += getChar();
      if (hdgset != hdgsetold) {
        lcd1.setCursor(0, 1);
        lcd1.print("IAS        ");
        lcd1.setCursor(0, 1);
        lcd1.print("IAS " + hdgset);
      }
      break;
    case 'G': // found AP heading setting
      delay (11);
      flaps = "";
      flaps += getChar();
      flaps += getChar();
      flaps += getChar();
      if (flaps != flapsold) {
        lcd2.setCursor(0, 0);
        lcd2.print("Fp        ");
        lcd2.setCursor(0, 0);
        lcd2.print("Fp " + flaps);
      }
      break;
    case 'L': // found AP heading setting
      delay (11);
      vertsp = "";
      vertsp += getChar();
      vertsp += getChar();
      vertsp += getChar();
      vertsp += getChar();
      vertsp += getChar();
      vertsp += getChar();
      if ( vertsp !=  vertspold) {
        lcd2.setCursor(0, 1);
        lcd2.print("VS        ");
        lcd2.setCursor(0, 1);
        lcd2.print("VS " +  vertsp);
      }
      break;
    case 'A': // found AP heading setting
      delay (11);
      g = "";
      g += getChar();
      g += getChar();
      g += getChar();

      if ( g !=  gold) {
        lcd2.setCursor(0, 10);
        lcd2.print(" N        ");
        lcd2.setCursor(0, 10);
        lcd2.print("N " +  10);
      }
      break;

  }//end of case switch
}// end of void equals


void QUESTION() {   // The first identifier was "?"
  //do something
}// end of question

void SLASH() {   // The first identifier was "/" (Annunciator)
  //Do something
}

void INPUTS()
{
  Kstringnewstate = "";
  for (int KpinNo = 2; KpinNo < 20; KpinNo++) { // Pins 22 thru to 69 are all inputs
    KpinStateSTR = String(digitalRead(KpinNo));
    KoldpinStateSTR = String(Kstringoldstate.charAt(KpinNo - 22));//the 22 needs to be the same as the 22 in the "for" loop line.
    if (KpinStateSTR != KoldpinStateSTR)
    {
      if (KpinNo != 13) { // avoid using pin 13 as an input unless you know the tricks.
        if (KpinNo == 2 && KpinStateSTR == "0") {
          Serial.println ("Y03");
        }
        if (KpinNo == 2 && KpinStateSTR == "1") {
          Serial.println ("Y031");
        }

        // add more direct inputs here but raise the pinNo (35) in the above live and the line below.
        //now the "keys" bit. Note the pinNo 35 in the line above and the line below.
        if (KpinNo > 35) {
          Serial.print ("D");
          if (KpinNo < 10) Serial.print ("0");
          Serial.print (KpinNo);
          Serial.println (KpinStateSTR);
        }//end of "keys" bit
      }//end of yes it's different
      Kstringnewstate += KpinStateSTR;
    }//end of "for" loop
    Kstringoldstate = Kstringnewstate;
  }
void ENCODER(){
R = (quad1.position() / 2); //The /2 is to suit the encoder(See my website)
    if (R != Rold) { // checks to see if it different
      (Rdif = (R - Rold)); // finds out the difference
      if (Rdif == 1) Serial.println ("Y0310000");//Com1 Mhz down
      if (Rdif == -1) Serial.println ("Y0350000"); //Com1 Mhz up
      Rold = R; // overwrites the old reading with the new one.
    }
    R2 = (quad2.position());
    if (R2 != Rold2) {
      (Rdif2 = (R2 - Rold2));
      if (Rdif2 == 1) Serial.println ("Y0410000"); // Com1 Khz down
      if (Rdif2 == -1) Serial.println ("Y0450000");//Com1 Khz up
      Rold2 = R2;
    }
    R3 = (quad3.position());
    if (R3 != Rold3) {
      (Rdif3 = (R3 - Rold3));
      if (Rdif3 == 1) Serial.println ("Y0410000"); // VOR bug down
      if (Rdif3 == -1) Serial.println ("Y0450000"); //VOR bug up
      Rold3 = R3;
    }
  }

If you did a proper auto-format you will see that the last line is not a '}'

The problem lays here:

void SLASH()     // The first identifier was "/" (Annunciator)
{
  //Do something
}

void INPUTS()
{
  ...
  ...
  }
  void ENCODER()
  {
    ...
    ...
  }

Any function should start at the beginning of a line after an auto-format.

Your INPUTS() is missing a closing '}'

Thank you so much for the hassle, Really appreciated. I must admit making collages of different programs is not a good idea for a beginner and I should really write from 0.