Does Not Name a Type Error

Hi, I have searched for an answer for this error and there definitely are some topics on it, just none have worked for me.

The program will eventually be part of a bigger program that has 3 different height buttons and a button to ‘set’ each height.

4 buttons, 4 LED’s indicating which button you’ve pressed.

Just got a program working for 1 button and LED to make the LED stay lit even after the button has been let go.

I then copied and pasted the code and changed the names to do it for a second LED but it threw this error up.

I will also want to eventually make the LED of the current button turn off when a new LED is pressed if anyones any suggestions

I’m a complete novice and have next to no experience programming so excuse the shoddiness.

Thank you in advance.

const int SetButtonPin = 16;
const int LowButtonPin = 17;
const int MedButtonPin = 18;
const int HighButtonPin = 19;

const int SetLEDPin = 13;
const int LowLEDPin = 2;
const int MedLEDPin = 8;
const int HighLEDPin = 7;

int SetButtonState = 1;
int LowButtonState = 1;
int MedButtonState = 1;
int HighButtonState = 1;


int SetButtonPushCounter = 0;
int SetLastButtonState = 0;
int LowButtonPushCounter = 0;
int LowLastButtonState = 0;
int MedButtonPushCounter = 0;
int MedLastButtonState = 0;
int HighButtonPushCounter = 0;
int HighLastButtonState = 0;


int SetLEDState = 0;
int LowLEDState = 0;
int MedLEDState = 0;
int HighLEDState = 0;

boolean flag = true;

unsigned long LastSetDebounceTime = 0;
unsigned long LastLowDebounceTime = 0;
unsigned long LastMedDebounceTime = 0;
unsigned long LastHighDebounceTime = 0;
unsigned long debounceDelay = 50;



void setup() {
  // put your setup code here, to run once:

pinMode (SetButtonPin,INPUT_PULLUP);
pinMode (LowButtonPin, INPUT_PULLUP);
pinMode (MedButtonPin, INPUT_PULLUP);
pinMode (HighButtonPin, INPUT_PULLUP);

pinMode (SetLEDPin, OUTPUT);
pinMode (LowLEDPin, OUTPUT);
pinMode (MedLEDPin, OUTPUT);
pinMode (HighLEDPin, OUTPUT);

Serial.begin(9600);

digitalWrite(LowLEDPin, LowButtonPin);

}

void loop() {



  // Start of Set button Working;

  int reading = digitalRead(SetButtonPin);

SetButtonState = digitalRead(SetButtonPin);


if (reading != SetLastButtonState) {
  LastSetDebounceTime = millis();
}

if ((millis() - LastSetDebounceTime) > debounceDelay) {

  if(reading != SetButtonState) {
    SetButtonState = reading;

    if (SetButtonState == HIGH) {
      SetButtonState = !LowLEDState;
    }
  }
}


if (digitalRead(SetButtonPin)==LOW){  
  delay(5);
      flipflop(); 
  }

  // other sketch code here

} // end of main loop.

void flipflop(){  
  flag = !flag;  
  Serial.print("flag =   " );   Serial.println(flag);  

  if (flag == HIGH){  
    digitalWrite(SetLEDPin,HIGH ); 
  }
  if (flag == LOW) {
    digitalWrite(SetLEDPin,LOW);
  }
  while(digitalRead(SetButtonPin)==LOW); 
  delay(50); 
 

}

  
  
 // Start of Low button Working;

  int reading = digitalRead(LowButtonPin); 
  LowButtonState = digitalRead(LowButtonPin); //This is where the Error is.


if (reading != LowLastButtonState) {
  LastLowDebounceTime = millis();
}

if ((millis() - LastLowDebounceTime) > debounceDelay) {

  if(reading != LowButtonState) {
    LowButtonState = reading;

    if (LowButtonState == HIGH) {
      LowButtonState = !LowLEDState;
    }
  }
}


if (digitalRead(LowButtonPin)==LOW){  
  delay(5);
      flipflop(); 
  }

  // other sketch code here

} // end of main loop.

void flipflop(){  
  flag = !flag;  
  Serial.print("flag =   " );   Serial.println(flag);  

  if (flag == HIGH){  
    digitalWrite(LowLEDPin,HIGH ); 
  }
  if (flag == LOW) {
    digitalWrite(LowLEDPin,LOW);
  }
  while(digitalRead(LowButtonPin)==LOW); 
  delay(50); 

}

You've made copy/paste errors

As a result, a lot of statements are outside functions. Check the part after the end of the first flipflop() function.