Program Error - a function-definition is not allowed here before '{' token

Hey There! I'm having some coding issues...probably silly ones that can be resolved very quickly by trained eyes. I am getting the above error for one of my functions. I have attached the whole program but my errors are related to the self() function. I think it was to do with were it is placed, but I am unsure. Any advice is greatly appreciated.

/
/************************************************************
File: roller_01
Revision:
Date:
Author:

Description:

  • roller control - one window

  • 3 analog sensors:

  • outside temp.

  • inside temp.

  • light

  • 3 digital sensors for roller position

  • 3 swithces for manual mode operation

**************************************************************/

//*************************************************************
//**** include files ******************************************
//*************************************************************

#include <AFMotor.h>

//*************************************************************
//**** variables **********************************************
//*************************************************************

//**** motor control ****

AF_DCMotor motor(1);

int forwardPin = 52;
int reversePin = 51;
int stopPin = 50;

//*** light barriers - open = LOW ; blocked = HIGH *********

int roller_up_sensor = 49;
int roller_middle_sensor = 48;
int roller_down_sensor = 47;

int manual = 46;

int forwardFlag;
int reverseFlag;

//**** temp. & light ****

int temp_outside;
int temp_inside;
int light;

float temp_out_C;
float temp_in_C;
float light_C;

int tempPin1 = 0; // Analog Input Pin for Outdoor Temperature
int tempPin2 = 1; // Analog Input Pin for Indoor Temperature
int lightPin = 2; // Analog Input Pin for Outdoor Light Sensor

//**** constant values *****************************************

const int temp_inside_normal = 21; // expected normal temperature inside
const int sunny = 50; // light sensor value for sunny conditions
const int night = 10; // light sensor value for night conditions

//**************************************************************
// **** setup **************************************************
//**************************************************************

void setup()
{
Serial.begin(9600); // set up Serial library at 9600 bps

pinMode(forwardPin, INPUT_PULLUP);
pinMode(reversePin, INPUT_PULLUP);
pinMode(stopPin, INPUT_PULLUP);

pinMode(roller_up_sensor, INPUT);
pinMode(roller_middle_sensor, INPUT);
pinMode(roller_down_sensor, INPUT);

pinMode(manual, INPUT);

forwardFlag = 0;
reverseFlag = 0;

motor.setSpeed(255);
motor.run(RELEASE);
}

//**************************************************************
//**** main loop ***********************************************
//**************************************************************

void self() {

}

void loop()
{

start: if (!digitalRead(manual)) goto man; //Digital Pin for Manual Control - toggle switch - if not high go to manual routine

//**** read analog sensors ***********************************

aut: temp_outside = analogRead(tempPin1); //read outdoor temperature

temp_inside = analogRead(tempPin2); //read indoor temperature

light = analogRead(lightPin); //read light sensor

//**** convert sensors data to physical values ****************

temp_out_C = temp_outside * 0.48828125; //convert raw data into degrees Celsius (500mV/1024 = 0.48828125)

temp_in_C = temp_inside * 0.48828125; //convert raw data into degrees Celsius (500mV/1024 = 0.48828125)

light_C = (light / 1024) * 100; //convert raw light data to percentage

//****************************************************************************************************************
// if inside temperature is lower than (normal - 1) or higher than (normal + 1) run the Roller routine
// else - don't do anything
//****************************************************************************************************************

if ((temp_inside > temp_inside_normal + 10) || (temp_inside < temp_inside_normal - 10)) Window_Roller_On();

//*** stamp time, do screen display and write to SD card here *******

//delay(10000); // do the loop every 10 sec.

goto start;

man: self(); //Self Function - Run Self Function - Line 214

}

//**************************************************************
//**** local functions *****************************************
//**************************************************************

void Window_Roller_On()
{
if ((light >= sunny) || (light <= night)) // sun on window or night time --> close roller
{
if (temp_outside < temp_inside) // cooler outside - close half for fresh air
{
if (digitalRead(roller_down_sensor)) // if roller is in down position
{
motor.run(BACKWARD); // run roller up...

while (!digitalRead(roller_middle_sensor)); // ... until middle position sensor reached

motor.run(RELEASE); // when roller in middle position - stop motor

}

if (digitalRead(roller_up_sensor)) // if roller is in up position
{
motor.run(FORWARD); // run roller down...

while (!digitalRead(roller_middle_sensor)); // ... until middle position sensor reached

motor.run(RELEASE); // when roller in middle position - stop motor
}

// *** if roller already in middle position - do nothing ****

}

if (temp_outside >= temp_inside) // warm outside - close whole roller
{
if (digitalRead(roller_up_sensor) || digitalRead(roller_middle_sensor)) // if roller is up or in middle position
{
motor.run(FORWARD); // run roller down...

while (!digitalRead(roller_down_sensor)); // ... until down position sensor reached

motor.run(RELEASE); // when roller in down position - stop motor

// *** if roller already in down position - do nothing ****

}
}

if ((light < sunny) && (light > night)) // daylight but no sun --> roller open
{
if (digitalRead(roller_middle_sensor) || digitalRead(roller_down_sensor)) // if roller is in middle or down position
{
motor.run(BACKWARD); // run roller up...

while (!digitalRead(roller_up_sensor)); // ... until up position sensor reached

motor.run(RELEASE); // when roller in up position - stop motor

}

// *** if roller already in up position - do nothing ****

}//end of Window_Roller_On()

//*********************************************************************************

void self()
if (!digitalRead(forwardPin))
{
if (reverseFlag)
{
motor.run(RELEASE);
reverseFlag = 0;
delay(2000);
}
forwardFlag = 1;
motor.run(FORWARD);
}

if (!digitalRead(reversePin))
{
if (forwardFlag)
{
motor.run(RELEASE);
forwardFlag = 0;
delay(2000);
}
reverseFlag = 1;
motor.run(BACKWARD);
}
if (!digitalRead(stopPin))
{
forwardFlag = 0;
reverseFlag = 0;
motor.run(RELEASE);
}

} //end of manual()

The code inside self() at the bottom isn't inside self() since you left out the {} so none of those lines is inside a function.

And as it stands, the last }//end of manual right at the bottom, currently partners a { waaaay up in Window_roller_on().

When you hover your mouse next to a { or } the IDE highlights the corresponding } or {.

You should do a ctrl-T to tidy up the formatting.

There is a second void self() {//empty} at the top.
Leo..

Use CTRL T to format the sketch.
Please use code tags.
Use the </> icon in the posting menu.

[code] Paste sketch here. [/code]

And when the self(){} mess is sorted out I daresay there'll be a discussion about the desirability of using goto?

You also have ; on the ends of your whiles.

while (!digitalRead(roller_down_sensor));   // ... until down position sensor reached

motor.run(RELEASE);                         // when roller in down position - stop motor

And probably mean this:

while (!digitalRead(roller_down_sensor))   // ... until down position sensor reached
{
motor.run(RELEASE);                         // when roller in down position - stop motor
}

See here.

Thanks everyone for the replies. I will make changes and see what happens.