erroe was not declared in this scope

I am trying to write a sketch to control a set of relays for long timed runs over the week but have hit a snag in my code. I have combined a couple of sketches i found on line and in the examples from the librayers but cant seem to figure out what i did wrong.

Timer_Control.ino: In function 'void setup()':
Timer_Control.ino:47:39: error: 'SaterdayAlarm' was not declared in this scope
Timer_Control.ino:48:27: error: 'EveningAlarm' was not declared in this scope
Timer_Control.ino: In function 'void loop()':
Timer_Control.ino:122:21: error: a function-definition is not allowed here before '{' token
Timer_Control.ino:141:20: error: a function-definition is not allowed here before '{' token
Error compiling.
//RTC CONNECTIONS
//Connect the RTC VCC  to the Arduino  +5 v
//                       RTC GND to the Arduino GND
//                       RTC SDA to  the Arduino Analog Pin 4
//                       RTC SCL to  the Arduino Analog Pin 5

// LCD DISPLAY CONNECTION
#define sclk 4     //connected to digital PIN 4 
#define mosi 5     //connected to digital PIN 5
#define cs   6     //connected to digital PIN 6
#define dc   7     //connected to digital PIN 7
#define rst  8     //connected to digital PIN 8

// RELAY CONNECTION
// GND connected to Arduino GND
#define RELAY1 9                 // IN1 connected to digital 9
#define RELAY2 10                // IN2 connected to digital 10
#define RELAY3 11                // IN3 connected to digital 11
#define RELAY4 12                // IN4 connected to digital 12
// VCC connected to Arduino +5v

// LED CONNECTION
#define LED 13                    // the pin for the LED

// BUTTON CONNECTION
#define BUTTON 14              // the input pin where the pushbutton is connected

#include "Adafruit_GFX.h" // Core graphics library
#include "Adafruit_ST7735.h" // Hardware-specific library
#include "SPI.h" // library needed for RTC
#include "RTClib.h" //RTC Library
#include "Wire.h"
#include "Time.h"
#include "TimeAlarms.h"

RTC_DS1307 RTC;

Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk, rst);

void setup() {
  // create the alarms 
Alarm.alarmRepeat(dowSaturday,9,30,00,SaterdayAlarm);  // 9:30:00 every Saturday 
Alarm.alarmRepeat(20,00,0,EveningAlarm);               // 8:00pm every day 

  // DEFINING PINS FOR RELAY CONTROL
pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);
pinMode(RELAY3, OUTPUT);
pinMode(RELAY4, OUTPUT);
pinMode(LED, OUTPUT);
pinMode(BUTTON, INPUT);
Wire.begin();
RTC.begin();

  tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab

  tft.fillScreen(ST7735_BLACK); // Clear screen
  digitalWrite(RELAY1, 1 );
  digitalWrite(RELAY2, 1 );
  digitalWrite(RELAY3, 1 );
  digitalWrite(RELAY4, 1 );
  tft.setCursor(0,50);
  tft.println("  Waiting 10 seconds ");
  tft.println("   for RTC  to Sync ");
  delay(10000);//wait for RTC to Respond, if not set time
  tft.fillScreen(ST7735_BLACK); // Clear screen
if (! RTC.isrunning()) {
    tft.println("  RTC was NOT running!");
    tft.println("     Resetting RTC ");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  
    tft.fillScreen(ST7735_BLACK); // Clear screen
    
  }
}

void loop() {
  tft.setCursor(10,10);
   tft.setTextColor(ST7735_WHITE);
   tft.setTextSize(1);
   tft.println("TIMER CONTROL");
  
      tft.setTextColor(ST7735_YELLOW,ST7735_BLACK);//set text color & size for  DATE coming from TinyRTC
      tft.setTextSize(2);
      tft.setCursor(5,30);
      DateTime now = RTC.now(); //GRAB DATE AND TIME FROM RTC
      tft.print(now.year(), DEC);
      tft.print('/');
      tft.print(now.month(), DEC);
      tft.print('/');
      tft.print(now.day(), DEC);
      tft.println(' ');
      tft.setCursor(15,70);
      tft.setTextColor(ST7735_GREEN,ST7735_BLACK); //set color for TIME
      tft.setTextSize(2);//set text  size for  TIME coming from TinyRTC
      tft.print(now.hour(), DEC);
      tft.print(':');
      if(now.minute() < 10) { //PRINT A 0 IN FRONT OF THE MINUTE IF LESS THAN 10
      tft.print('0');
      tft.print(now.minute(), DEC);
      }
       else {
       tft.print(now.minute(), DEC);
      }
       tft.print(':');
      if(now.second() < 10) {//PRINT A 0 IN FRONT OF THE SECONDS IF LESS THAN 10
      tft.print('0');
      tft.print(now.second(), DEC);
      }
       else {
       tft.print(now.second(), DEC);
      }
      tft.println(" ");

// functions to be called when an alarm triggers:
void SaterdayAlarm(){
     digitalWrite(RELAY1, LOW);  
     digitalWrite(RELAY2, HIGH); 
     digitalWrite(RELAY3, LOW); 
     digitalWrite(RELAY4, HIGH);
     digitalWrite(LED,HIGH);
      tft.setCursor(0,100);
      tft.setTextColor(ST7735_RED,ST7735_BLACK); //set color for TIME ON
      tft.setTextSize(1);//set text  size
      tft.setTextColor(ST7735_GREEN,ST7735_BLACK);
      tft.println("1 is on ");
      tft.setTextColor(ST7735_RED,ST7735_BLACK);
      tft.println("Spark is off ");
      tft.setTextColor(ST7735_GREEN,ST7735_BLACK);
      tft.println("Relay 3 is on ");
      tft.setTextColor(ST7735_RED,ST7735_BLACK);
      tft.println("Relay 4 is off ");
    }

void EveningAlarm(){
     digitalWrite(RELAY1, HIGH);  
     digitalWrite(RELAY2, HIGH);  
     digitalWrite(RELAY3, HIGH);  
     digitalWrite(RELAY4, HIGH);
     digitalWrite(LED,LOW);
      tft.setCursor(0,100);
      tft.setTextColor(ST7735_RED,ST7735_BLACK); //set color for TIME ON
      tft.setTextSize(1);//set text  size
      tft.println("1 is off ");
      tft.println("Spark is off ");
      tft.println("Relay 3 is off ");
      tft.println("Relay 4 is off ");  
    }
}

You're missing a closing brace after the loop function. So the two function definitions appear to be inside of loop. Use control-T to auto-format the code and it will line up the braces for you so you can see where you're messed up.

well i must be blind because i can not see a missing bracket in the loop or setup section or the script. when i hit command-T it says no changes necessary for auto format.

//RTC CONNECTIONS
//Connect the RTC VCC  to the Arduino  +5 v
//                       RTC GND to the Arduino GND
//                       RTC SDA to  the Arduino Analog Pin 4
//                       RTC SCL to  the Arduino Analog Pin 5

// LCD DISPLAY CONNECTION
#define sclk 4     //connected to digital PIN 4 
#define mosi 5     //connected to digital PIN 5
#define cs   6     //connected to digital PIN 6
#define dc   7     //connected to digital PIN 7
#define rst  8     //connected to digital PIN 8

// RELAY CONNECTION
// GND connected to Arduino GND
#define RELAY1 9                 // IN1 connected to digital 9
#define RELAY2 10                // IN2 connected to digital 10
#define RELAY3 11                // IN3 connected to digital 11
#define RELAY4 12                // IN4 connected to digital 12
// VCC connected to Arduino +5v

// LED CONNECTION
#define LED 13                    // the pin for the LED

// BUTTON CONNECTION
#define BUTTON 14              // the input pin where the pushbutton is connected

#include "Adafruit_GFX.h" // Core graphics library
#include "Adafruit_ST7735.h" // Hardware-specific library
#include "SPI.h" // library needed for RTC
#include "RTClib.h" //RTC Library
#include "Wire.h"
#include "Time.h"
#include "TimeAlarms.h"

RTC_DS1307 RTC;

Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk, rst);

void setup() {
  // create the alarms
  Alarm.alarmRepeat(dowSaturday, 9, 30, 00, SaterdayAlarm); // 9:30:00 every Saturday
  Alarm.alarmRepeat(20, 00, 0, EveningAlarm);            // 8:00pm every day

  // DEFINING PINS FOR RELAY CONTROL
  pinMode(RELAY1, OUTPUT);
  pinMode(RELAY2, OUTPUT);
  pinMode(RELAY3, OUTPUT);
  pinMode(RELAY4, OUTPUT);
  pinMode(LED, OUTPUT);
  pinMode(BUTTON, INPUT);
  Wire.begin();
  RTC.begin();

  tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab

  tft.fillScreen(ST7735_BLACK); // Clear screen
  digitalWrite(RELAY1, 1 );
  digitalWrite(RELAY2, 1 );
  digitalWrite(RELAY3, 1 );
  digitalWrite(RELAY4, 1 );
  tft.setCursor(0, 50);
  tft.println("  Waiting 10 seconds ");
  tft.println("   for RTC  to Sync ");
  delay(10000);//wait for RTC to Respond, if not set time
  tft.fillScreen(ST7735_BLACK); // Clear screen
  if (! RTC.isrunning()) {
    tft.println("  RTC was NOT running!");
    tft.println("     Resetting RTC ");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));

    tft.fillScreen(ST7735_BLACK); // Clear screen

  }
}

void loop() {
  tft.setCursor(10, 10);
  tft.setTextColor(ST7735_WHITE);
  tft.setTextSize(1);
  tft.println("TIMER CONTROL");

  tft.setTextColor(ST7735_YELLOW, ST7735_BLACK); //set text color & size for  DATE coming from TinyRTC
  tft.setTextSize(2);
  tft.setCursor(5, 30);
  DateTime now = RTC.now(); //GRAB DATE AND TIME FROM RTC
  tft.print(now.year(), DEC);
  tft.print('/');
  tft.print(now.month(), DEC);
  tft.print('/');
  tft.print(now.day(), DEC);
  tft.println(' ');
  tft.setCursor(15, 70);
  tft.setTextColor(ST7735_GREEN, ST7735_BLACK); //set color for TIME
  tft.setTextSize(2);//set text  size for  TIME coming from TinyRTC
  tft.print(now.hour(), DEC);
  tft.print(':');
  if (now.minute() < 10) { //PRINT A 0 IN FRONT OF THE MINUTE IF LESS THAN 10
    tft.print('0');
    tft.print(now.minute(), DEC);
  }
  else {
    tft.print(now.minute(), DEC);
  }
  tft.print(':');
  if (now.second() < 10) { //PRINT A 0 IN FRONT OF THE SECONDS IF LESS THAN 10
    tft.print('0');
    tft.print(now.second(), DEC);
  }
  else {
    tft.print(now.second(), DEC);
  }
  tft.println(" ");

  // functions to be called when an alarm triggers:
  void SaterdayAlarm() {
    digitalWrite(RELAY1, LOW);
    digitalWrite(RELAY2, HIGH);
    digitalWrite(RELAY3, LOW);
    digitalWrite(RELAY4, HIGH);
    digitalWrite(LED, HIGH);
    tft.setCursor(0, 100);
    tft.setTextColor(ST7735_RED, ST7735_BLACK); //set color for TIME ON
    tft.setTextSize(1);//set text  size
    tft.setTextColor(ST7735_GREEN, ST7735_BLACK);
    tft.println("1 is on ");
    tft.setTextColor(ST7735_RED, ST7735_BLACK);
    tft.println("Spark is off ");
    tft.setTextColor(ST7735_GREEN, ST7735_BLACK);
    tft.println("Relay 3 is on ");
    tft.setTextColor(ST7735_RED, ST7735_BLACK);
    tft.println("Relay 4 is off ");
  }

  void EveningAlarm() {
    digitalWrite(RELAY1, HIGH);
    digitalWrite(RELAY2, HIGH);
    digitalWrite(RELAY3, HIGH);
    digitalWrite(RELAY4, HIGH);
    digitalWrite(LED, LOW);
    tft.setCursor(0, 100);
    tft.setTextColor(ST7735_RED, ST7735_BLACK); //set color for TIME ON
    tft.setTextSize(1);//set text  size
    tft.println("1 is off ");
    tft.println("Spark is off ");
    tft.println("Relay 3 is off ");
    tft.println("Relay 4 is off ");
  }
}

OK, technically it’s not missing I guess because there is an extra closing brace at the very end so it end’s up balancing out. I guess technically it’s just in the wrong place.

Here is your code with a couple of comments showing where. I put them in all caps so they’re easy to find.

//RTC CONNECTIONS
//Connect the RTC VCC  to the Arduino  +5 v
//                       RTC GND to the Arduino GND
//                       RTC SDA to  the Arduino Analog Pin 4
//                       RTC SCL to  the Arduino Analog Pin 5

// LCD DISPLAY CONNECTION
#define sclk 4     //connected to digital PIN 4 
#define mosi 5     //connected to digital PIN 5
#define cs   6     //connected to digital PIN 6
#define dc   7     //connected to digital PIN 7
#define rst  8     //connected to digital PIN 8

// RELAY CONNECTION
// GND connected to Arduino GND
#define RELAY1 9                 // IN1 connected to digital 9
#define RELAY2 10                // IN2 connected to digital 10
#define RELAY3 11                // IN3 connected to digital 11
#define RELAY4 12                // IN4 connected to digital 12
// VCC connected to Arduino +5v

// LED CONNECTION
#define LED 13                    // the pin for the LED

// BUTTON CONNECTION
#define BUTTON 14              // the input pin where the pushbutton is connected

#include "Adafruit_GFX.h" // Core graphics library
#include "Adafruit_ST7735.h" // Hardware-specific library
#include "SPI.h" // library needed for RTC
#include "RTClib.h" //RTC Library
#include "Wire.h"
#include "Time.h"
#include "TimeAlarms.h"

RTC_DS1307 RTC;

Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk, rst);

void setup() {
  // create the alarms
  Alarm.alarmRepeat(dowSaturday, 9, 30, 00, SaterdayAlarm); // 9:30:00 every Saturday
  Alarm.alarmRepeat(20, 00, 0, EveningAlarm);            // 8:00pm every day

  // DEFINING PINS FOR RELAY CONTROL
  pinMode(RELAY1, OUTPUT);
  pinMode(RELAY2, OUTPUT);
  pinMode(RELAY3, OUTPUT);
  pinMode(RELAY4, OUTPUT);
  pinMode(LED, OUTPUT);
  pinMode(BUTTON, INPUT);
  Wire.begin();
  RTC.begin();

  tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab

  tft.fillScreen(ST7735_BLACK); // Clear screen
  digitalWrite(RELAY1, 1 );
  digitalWrite(RELAY2, 1 );
  digitalWrite(RELAY3, 1 );
  digitalWrite(RELAY4, 1 );
  tft.setCursor(0, 50);
  tft.println("  Waiting 10 seconds ");
  tft.println("   for RTC  to Sync ");
  delay(10000);//wait for RTC to Respond, if not set time
  tft.fillScreen(ST7735_BLACK); // Clear screen
  if (! RTC.isrunning()) {
    tft.println("  RTC was NOT running!");
    tft.println("     Resetting RTC ");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));

    tft.fillScreen(ST7735_BLACK); // Clear screen

  }
}   //  END OF SETUP

void loop() {
  tft.setCursor(10, 10);
  tft.setTextColor(ST7735_WHITE);
  tft.setTextSize(1);
  tft.println("TIMER CONTROL");

  tft.setTextColor(ST7735_YELLOW, ST7735_BLACK); //set text color & size for  DATE coming from TinyRTC
  tft.setTextSize(2);
  tft.setCursor(5, 30);
  DateTime now = RTC.now(); //GRAB DATE AND TIME FROM RTC
  tft.print(now.year(), DEC);
  tft.print('/');
  tft.print(now.month(), DEC);
  tft.print('/');
  tft.print(now.day(), DEC);
  tft.println(' ');
  tft.setCursor(15, 70);
  tft.setTextColor(ST7735_GREEN, ST7735_BLACK); //set color for TIME
  tft.setTextSize(2);//set text  size for  TIME coming from TinyRTC
  tft.print(now.hour(), DEC);
  tft.print(':');
  if (now.minute() < 10) { //PRINT A 0 IN FRONT OF THE MINUTE IF LESS THAN 10
    tft.print('0');
    tft.print(now.minute(), DEC);
  }
  else {
    tft.print(now.minute(), DEC);
  }
  tft.print(':');
  if (now.second() < 10) { //PRINT A 0 IN FRONT OF THE SECONDS IF LESS THAN 10
    tft.print('0');
    tft.print(now.second(), DEC);
  }
  else {
    tft.print(now.second(), DEC);
  }
  tft.println(" ");

     //  YOU'RE MISSING A CLOSING BRACKET HERE.  THIS SHOULD BE THE END OF LOOP

  // functions to be called when an alarm triggers:
  void SaterdayAlarm() {
    digitalWrite(RELAY1, LOW);
    digitalWrite(RELAY2, HIGH);
    digitalWrite(RELAY3, LOW);
    digitalWrite(RELAY4, HIGH);
    digitalWrite(LED, HIGH);
    tft.setCursor(0, 100);
    tft.setTextColor(ST7735_RED, ST7735_BLACK); //set color for TIME ON
    tft.setTextSize(1);//set text  size
    tft.setTextColor(ST7735_GREEN, ST7735_BLACK);
    tft.println("1 is on ");
    tft.setTextColor(ST7735_RED, ST7735_BLACK);
    tft.println("Spark is off ");
    tft.setTextColor(ST7735_GREEN, ST7735_BLACK);
    tft.println("Relay 3 is on ");
    tft.setTextColor(ST7735_RED, ST7735_BLACK);
    tft.println("Relay 4 is off ");
  }

  void EveningAlarm() {
    digitalWrite(RELAY1, HIGH);
    digitalWrite(RELAY2, HIGH);
    digitalWrite(RELAY3, HIGH);
    digitalWrite(RELAY4, HIGH);
    digitalWrite(LED, LOW);
    tft.setCursor(0, 100);
    tft.setTextColor(ST7735_RED, ST7735_BLACK); //set color for TIME ON
    tft.setTextSize(1);//set text  size
    tft.println("1 is off ");
    tft.println("Spark is off ");
    tft.println("Relay 3 is off ");
    tft.println("Relay 4 is off ");
  }
}     //  THIS IS THE CLOSING BRACKET FOR LOOP FUNCTION.  IT SHOULD BE UP THERE WHERE THE ONE IS MISSING

Ok that makes me fell not quite as dumb as i did. Now to get the rest of my ides in the code :D

thank you. and i am sure i will be asking for more help in the next few days.

In the IDE, you can put the cursor to the right of a }, where the comma is above, and it will highlight the mating { so you can see what section of code is implemented in between { and }. Very handy. Also works for ( and )

Hi, i saw u using the RTC module. can you pls share the link you download the RTC related libraries pls?

Thanks

The OP last posted on 06-04-2015, 19:35:49 so you are unlikely to get a reply from him/her.

I assume that you have done Google search.