Combining LED code with master code ERRORS

I am trying to add a simple code to manually turn on/off multiple LEDs. When I try to add the code into the master code, I get errors with other portions of the project such as the clock modules. The concept of the project is to control multiple light arrays while reading the amount of lux coming off of the light sources. The RTC clock modules is a way to adjust the amount of light being outputted based on the time of day. Below is the master code.

#include <TimeLib.h>
#include <TimeAlarms.h>
#include <Wire.h>
#include <SparkFunDS1307RTC.h>
#include <DS1307RTC.h>  // a basic DS1307 library that returns time as a time_t
#include <Adafruit_Sensor.h>
#include "Adafruit_TSL2591.h" // the photoresistor module

int LED1 = 9;
int LED2 = 10;
int LED3 = 6;

int brightness = 255; // how bright the LED is
int fadeAmount = 1; // how many points to fade the LED by
int targetbrightness = 255; // target brightness
Adafruit_TSL2591 tsl = Adafruit_TSL2591(2591);
//configure TSL2591
void configureSensor(void)
{
  tsl.setGain(TSL2591_GAIN_MED);
  tsl.setTiming(TSL2591_INTEGRATIONTIME_300MS);
  
  Serial.println(F("------------------------------------"));
  Serial.print  (F("Gain:         "));
  tsl2591Gain_t gain = tsl.getGain();
  switch(gain)
  {
    case TSL2591_GAIN_LOW:
      Serial.println(F("1x (Low)"));
      break;
    case TSL2591_GAIN_MED:
      Serial.println(F("25x (Medium)"));
      break;
    case TSL2591_GAIN_HIGH:
      Serial.println(F("428x (High)"));
      break;
    case TSL2591_GAIN_MAX:
      Serial.println(F("9876x (Max)"));
      break;
  }
  Serial.print  (F("Timing:       "));
  Serial.print((tsl.getTiming() + 1) * 100, DEC); 
  Serial.println(F(" ms"));
  Serial.println(F("------------------------------------"));
}
void setup() {
  // prepare pin as output
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  
  digitalWrite(LED1, HIGH); //turn on
  digitalWrite(LED2, HIGH); 
  digitalWrite(LED3, HIGH); 
  digitalWrite(LED1, LOW); //turn off
  digitalWrite(LED2, LOW); 
  digitalWrite(LED3, LOW); 
  
  Serial.begin(9600);
  rtc.autoTime();
  // wait for Arduino Serial Monitor
  while (!Serial) ;
  
  // get and set the time from the RTC
  setSyncProvider(RTC.get);  
  if (timeStatus() != timeSet)
     Serial.println("Unable to sync with the RTC");
  else
     Serial.println("RTC has set the system time");    
  
  // To test your project, we can set the time manually by uncommenting bottom line
  //setTime(8,29,0,1,1,11); // set time to Saturday 8:29:00am Jan 1 2011

  // create the alarms, to trigger functions at specific times
  Alarm.alarmRepeat(6,00,0,MorningAlarm);  // 9:00am every day
  Alarm.alarmRepeat(19,00,0,EveningAlarm);  // 19:00 -> 7:00pm every day
  // TSL2591
    Serial.println(F("Starting Adafruit TSL2591..."));
  
  if (tsl.begin()) 
  {
    Serial.println(F("Found a TSL2591 sensor"));
  } 
  else 
  {
    Serial.println(F("No sensor found ..."));
    while (1);
  }
  configureSensor();
}

// The first "flag" for checking the Lux levels. If the Lux level is less than 500 then luxCheck will be 0.
int luxCheck;

// Reads IR and full spectrum then converts to Lux and checks for less than 500 Lux value
void advancedRead(void)
{
  sensors_event_t event;
  tsl.getEvent(&event);
  uint32_t lum = tsl.getFullLuminosity();
  uint16_t ir, full;
  ir = lum >> 16;
  full = lum & 0xFFFF;
  Serial.println(tsl.calculateLux(full, ir), 6);
  if ((event.light < 500))
    {
      luxCheck = 0;
      Serial.println(F("WARNING: LUX NOT WITHIN DESIRED RANGE!"));
      Serial.print(F("Lux: ")); Serial.println(tsl.calculateLux(full, ir), 2);
    }
    else
      { 
        luxCheck = 1;
        Serial.print(F("Lux: ")); Serial.println(tsl.calculateLux(full, ir), 2);
      }
}


void loop() {

  analogWrite(LED1, brightness);
  if (hour() >= 6 && hour()<= 11) {
    brightness = brightness + fadeAmount/18000;
  }
  else if (hour() > 11 && hour() <= 19) {
    brightness = brightness - fadeAmount/28800;
  }
  else { brightness = 0;
  }

  
  
  // wait one second between each clock display in serial monitor
  Alarm.delay(1000);
  advancedRead();
}



// functions to be called when an alarm triggers
void MorningAlarm() {
  // write here the task to perform every morning
  Serial.println("Turn light on");
  digitalWrite(LED1, HIGH);
}
void EveningAlarm() {
  // write here the task to perform every evening
  Serial.println("Turn light off");
  digitalWrite(LED1, LOW);
}

void digitalClockDisplay() {
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.println();
}
void printDigits(int digits) {
  Serial.print(":");
  if (digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

What I am trying to do is to input the code to turn on/off each LED.

void setup() {

pinMode(9, OUTPUT); //set pin as output , red led

Serial.begin(9600); //start serial
}

void loop(){

if(Serial.available()){ //id data available

int val = Serial.read();

if(val == 1){ //if 1 received
digitalWrite(9, HIGH); //turn on
}
if(val == 2){ //if 2 received
digitalWrite(9, LOW); //turn off
}

}
}

Once I start adding the code into the loop portion, I get errors with the clock module. Any ideas?

Start by posting the combined code and the full error messages copied from the IDE

Start by reading this
http://www.thebox.myzen.co.uk/Tutorial/Merging_Code.html

Grumpy_Mike is correct! Also Get the Arduino cookbook and read it. Also on line there are many videos etc showing the Arduino and how to do what you want. This additional information will go a long way in getting your problem solved. Once you get past this you then need to select your sensors and actuators. At that point you start on the hardware design and write your software. I would suggest you read the cookbook first then the other will be much easier to understand.

UKHeliBob:
Start by posting the combined code and the full error messages copied from the IDE

#include <TimeLib.h>
#include <TimeAlarms.h>
#include <Wire.h>
#include <SparkFunDS1307RTC.h>
#include <WiFiNINA.h>
#include <DS1307RTC.h>  // a basic DS1307 library that returns time as a time_t
#include <Adafruit_Sensor.h>
#include "Adafruit_TSL2591.h" // the photoresistor module

int LED1 = 9;
int LED2 = 10;
int LED3 = 6;

int brightness = 255; // how bright the LED is
int fadeAmount = 1; // how many points to fade the LED by
int targetbrightness = 255; // target brightness
Adafruit_TSL2591 tsl = Adafruit_TSL2591(2591);
//configure TSL2591
void configureSensor(void)
{
  tsl.setGain(TSL2591_GAIN_MED);
  tsl.setTiming(TSL2591_INTEGRATIONTIME_300MS);
  
  Serial.println(F("------------------------------------"));
  Serial.print  (F("Gain:         "));
  tsl2591Gain_t gain = tsl.getGain();
  switch(gain)
  {
    case TSL2591_GAIN_LOW:
      Serial.println(F("1x (Low)"));
      break;
    case TSL2591_GAIN_MED:
      Serial.println(F("25x (Medium)"));
      break;
    case TSL2591_GAIN_HIGH:
      Serial.println(F("428x (High)"));
      break;
    case TSL2591_GAIN_MAX:
      Serial.println(F("9876x (Max)"));
      break;
  }
  Serial.print  (F("Timing:       "));
  Serial.print((tsl.getTiming() + 1) * 100, DEC); 
  Serial.println(F(" ms"));
  Serial.println(F("------------------------------------"));
}
void setup() {
  // prepare pin as output
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  
  digitalWrite(LED1, HIGH); //turn on
  digitalWrite(LED2, HIGH); 
  digitalWrite(LED3, HIGH); 
  digitalWrite(LED1, LOW); //turn off
  digitalWrite(LED2, LOW); 
  digitalWrite(LED3, LOW); 
  
  Serial.begin(9600);
  rtc.autoTime();
  // wait for Arduino Serial Monitor
  while (!Serial) ;
  
  // get and set the time from the RTC
  setSyncProvider(RTC.get);  
  if (timeStatus() != timeSet)
     Serial.println("Unable to sync with the RTC");
  else
     Serial.println("RTC has set the system time");    
  
  // To test your project, we can set the time manually by uncommenting bottom line
  //setTime(8,29,0,1,1,11); // set time to Saturday 8:29:00am Jan 1 2011

  // create the alarms, to trigger functions at specific times
  Alarm.alarmRepeat(6,00,0,MorningAlarm);  // 9:00am every day
  Alarm.alarmRepeat(19,00,0,EveningAlarm);  // 19:00 -> 7:00pm every day
  // TSL2591
    Serial.println(F("Starting Adafruit TSL2591..."));
  
  if (tsl.begin()) 
  {
    Serial.println(F("Found a TSL2591 sensor"));
  } 
  else 
  {
    Serial.println(F("No sensor found ..."));
    while (1);
  }
  configureSensor();
}

// The first "flag" for checking the Lux levels. If the Lux level is less than 500 then luxCheck will be 0.
int luxCheck;

// Reads IR and full spectrum then converts to Lux and checks for less than 500 Lux value
void advancedRead(void)
{
  sensors_event_t event;
  tsl.getEvent(&event);
  uint32_t lum = tsl.getFullLuminosity();
  uint16_t ir, full;
  ir = lum >> 16;
  full = lum & 0xFFFF;
  Serial.println(tsl.calculateLux(full, ir), 6);
  if ((event.light < 500))
    {
      luxCheck = 0;
      Serial.println(F("WARNING: LUX NOT WITHIN DESIRED RANGE!"));
      Serial.print(F("Lux: ")); Serial.println(tsl.calculateLux(full, ir), 2);
    }
    else
      { 
        luxCheck = 1;
        Serial.print(F("Lux: ")); Serial.println(tsl.calculateLux(full, ir), 2);
      }
}


void loop() {

  if(Serial.available()){ //id data available

  int val = Serial.read();

  if(val == 1){ //if 1 received
  digitalWrite(9, HIGH); //turn on
}
  if(val == 2){ //if 2 received
  digitalWrite(9, LOW); //turn off
}

  if(val == 1){ //if 1 received
  digitalWrite(10, HIGH); //turn on
}
  if(val == 2){ //if 2 received
  digitalWrite(10, LOW); //turn off
}
  if(val == 1){ //if 1 received
  digitalWrite(6, HIGH); //turn on
}
  if(val == 2){ //if 2 received
  digitalWrite(6, LOW); //turn off
}

  analogWrite(LED1, brightness);
  if (hour() >= 6 && hour()<= 11) {
    brightness = brightness + fadeAmount/18000;
  }
  else if (hour() > 11 && hour() <= 19) {
    brightness = brightness - fadeAmount/28800;
  }
  else { brightness = 0;
  }

  
  
  // wait one second between each clock display in serial monitor
  Alarm.delay(1000);
  advancedRead();
}



// functions to be called when an alarm triggers
void MorningAlarm() {
  // write here the task to perform every morning
  Serial.println("Turn light on");
  digitalWrite(LED1, HIGH);
}
void EveningAlarm() {
  // write here the task to perform every evening
  Serial.println("Turn light off");
  digitalWrite(LED1, LOW);
}

void digitalClockDisplay() {
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.println();
}
void printDigits(int digits) {
  Serial.print(":");
  if (digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

The error code says ‘MorningAlarm’ was not declared in this scope

press CRTL-T and see what happens to your code.

you have put functions in the loop which is a function itself.
check your brackets