Not declared error, Redefinition error, but can't seem to find anything wrong

Hello everyone,

I am working on an Arduino powered thermostat with damper adjustment features for a school project.

I am having some trouble with debugging a few odd errors that keep appearing in my program.
Let me just say right now, that I am very new to coding anything besides .bat files. Please excuse any giant and obvious errors that may be present.

Here is my code:

#include <Servo.h>
//#include <math.h>

boolean cool = false;
boolean heat = false; 
boolean fan = false; 
boolean off = false;
boolean on = false;
boolean FanON = false;

// Since There are no more pins avaliable, the main setpoint is hardcoded.
int MainSetPoint = 72;

//Fan or G (Green) wire
int Fan = 13;

//Compressor Cool Mode or B (Orange) wire
int Cool = 12;

//Heat Wire 
int Heat = 11;

//Secondary Heating or W2 (White) wire
int EmHeat = 10;

//Servo Object

Servo Damp1;

//Servo Damp2;

int angle = 0; //Default Servo Position

//LEDs
int LED1 = 7;
int LED2 = 8;

//Zone Potentiometers
int Z1PotPin = 5;
//int Z2PotPin = nil;
int z1val = 0;
int z2val = 0;

//Offsets for Temp Reads, adjust for temp accuracy if necessary - OFFSETS ARE IN CELCIUS. 
int maintoffset = 0;
int zone1offset = 0;
int zone2offset = 0;

//Inputs

int selsw = 6;
int onauto = 9;

void setup() { 
  
// Analog Output Pins for Servo Operation  
 
  //Servo PIN
  Damp1.attach(4);

  // declare fan pin to be an output
  pinMode(Fan, OUTPUT);
  
  // declare cool pin to be an output
  pinMode(Cool, OUTPUT);
  
  // declare heat pin to be an output
  pinMode(Heat, OUTPUT);
  
  // declare emheat pin to be an output
  pinMode(EmHeat, OUTPUT);
    
  // declare LED1 Pin to be an output
  pinMode(LED1, OUTPUT);
  
  // declare LED2 Pin to be an output
  pinMode(LED2, OUTPUT);
  
  // declare selector pin to be an input
  pinMode (selsw, INPUT);
  
  // Declare on/auto pin to be an input
  pinMode (onauto, INPUT);
 
}

  // SubRoutines - Relay Functions - Activate(Function) and Deactivate(Function). Functions are Fan, Cool, Heat, EmergencyHeat.

  // Selector subroutine
  int Selector() {
  int selswpos = analogRead(selsw); // Read value from selsw pin
  if (selswpos < 150) return 1; //Cool
  if (selswpos < 250) return 2; //Heat
  if (selswpos < 240) return 3; //Fan
  if (selswpos < 450) return 4; //EmHeat
  if (selswpos = 0) return 5; //if no input - return error mode
}

  //Fan ON  
  int ActivateFan() {
  (digitalWrite(Fan, HIGH));
}
 
  //Fan OFF
  int DeactivateFan() {
  (digitalWrite(Fan, LOW));
}
  
  //Cool ON
  int ActivateCool() {
  (digitalWrite(Cool, HIGH));
  while(true) boolean (Cool == true);
}
  
  //Cool OFF
  int DeactivateCool() {
  (digitalWrite(Cool, LOW));
  while(true) boolean (Cool == false);
}
  
  //Heat ON
  int ActivateHeat() {
  (digitalWrite(Heat, HIGH));
  while(true) boolean (Heat == true);
}
  
  //Heat OFF
  int DeactivateHeat() {
  (digitalWrite(Heat, LOW));
  while(true) boolean (Heat == false);
}
  
  //EmHeat ON
  int ActivateEmergencyHeat() {
  (digitalWrite(EmHeat, HIGH));
  while(true) boolean (EmHeat == true);
}
  
  //EmHeat OFF
  int DeactivateEmergencyHeat() {
  (digitalWrite(EmHeat, LOW));
  while(true) boolean (EmHeat == false);
}
  
  // SubRoutines - Damper Functions
  
  //Damper1 Adjustment
  int AdjDamper1(angle) {
  for(angle = 0; angle < 180; angle += 1)
  {
    Damper1.write(angle);
    delay(20); //20msec delay beteen servo commands
  }
  for(angle = 180; angle >=1; angle -= 1)
  {
	Damper1.write(angle);
	delay(20);
  }
}

  //Damper2 Adjustment
  int AdjDamper2(angle) {
  for(angle = 0; angle < 180; angle += 1)
  {
    Damper2.write(angle);
    delay(20); //20msec delay beteen servo commands
  }
  for(angle = 180; angle >=1; angle -= 1)
  {
	Damper2.write(angle);
	delay(20);
  }
}

  // SubRoutines - Sensor Input
  
  //Read Main Temp
  int ReadTempMain() {
  double T = Thermsister(analogRead(2));
}
  
  //Read Zone1 Temp
  int ReadTempZone1() {
  double Z1T = Zone1Temp(analogRead(3));
}
  
  //Read Zone1 Potentiometer (Setpoint)
  int ReadZone1Set() {
  z1val = analogRead(Z1PotPin);

  
  //Read Zone2 Potentiometer (Setpoint)
  int ReadZone2Set() {
  z2val = analogRead(Z2PotPin);
}
  
  // SubRoutines - Display Output
  
  //LED ON/OFF
  int LED1=on() {
  (digitalWrite(Led1,High));
}
  int LED1=off() {
  (digitalWrite(Led1,Low));
}
  int LED2=on() {(digitalWrite(Led2,High));
}
  int LED2=off() {
  (digitalWrite(Led2,Low));
}
  int LED2=flashing() {
  (void loop () {(digitalWrite(Led2,High)) delay(500) (digitalWrite(Led2,Low)));}
}
  
Serial.print("Ready.");

void loop() {
  // put your main code here, to run repeatedly:
 
 
double Thermister(int RawADC) {
  double Temp;
  // See http://en.wikipedia.org/wiki/Thermistor for explanation of formula
  Temp = log(((10240000/RawADC) - 10000));
  Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
  Temp = Temp - 273.15;           // Convert Kelvin to Celcius
  return Temp + maintoffSet * (9/5) + (32); // Add offset + convert to F
}

double Zone1Temp(int RawADC) {
  double Z1Temp;
  Temp = log(((10240000/RawADC) - 10000));
  Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
  Temp = Z1Temp - 273.15;           // Convert Kelvin to Celcius
  return Z1Temp + zone1offset * (9/5) + (32); // Add offset + convert to F
}
 
// MAIN PROGRAM IF FUNCTIONS

  //Damper Positioning - Zone 1
  if (Selector = 3) and ((ReadTempZone1+z1pot) +2 or -2 from ReadTempMain) then (AdjDamper1, 255), Serial.print("Open Damper 1.");
  if (Selector = 3) and ((ReadTempZone1+z1pot) = ReadTempMain) then (AdjDamper1, 30), Serial.print("Close Damper 1.");
  if (Selector = 1) and ((ReadTempZone1+z1pot) +2 from ReadTempMain) then (AdjDamper1, 255), Serial.print("Open Damper 1.");
  if (Selector = 1) and ((ReadTempZone1+z1pot) = ReadTempMain) then (AdjDamper1, 30), Serial.print("Close Damper 1.");
  if (Selector = 2) and ((ReadTempZone1-z1pot) -2 from ReadTempMain) then (AdjDamper1, 255), Serial.print("Open Damper 1.");
  if (Selector = 2) and ((ReadTempZone1-z1pot) = ReadTempMain) then (AdjDamper1, 30), Serial.print("Close Damper 1.");
  if (Selector = 4) then (AdjDamper1, 255), Serial.print("Emergency - Open Damper 1.");
  if (Selector = 5) then Serial.print ("Selector Fault Detected, Check Connections.");
    
  //CoolSystem
  if (Selector = Cool) and (ReadTempMain +1 or -1 from MainSetPoint) then (ActivateCool), (ActivateFan);

  //HeatSystem
  if (Selector = Heat) and (ReadTempMain +1 or -1 from MainSetPoint) then (ActivateHeat), (ActivateFan);
  
  //EMheatSystem
  if (Selector = EmHeat) and (ReadTempMain +1 or -1 from MainSetPoint) then (ActivateEmHeat), (ActivateFan);
  if (Selector = Heat) and (ReadTempMain +3 or -3 from MainSetPoint) then (ActivateEmHeat), (ActivateFan);

  //FanSystem
  if (FanON = True) then (ActivateFan);
  if (Selector = Fan) and (RedTempMain +2 or -2 from MainSetPoint) then (ActivateFan);
  
// Display Functions

  //Serial Out
  Serial.print("Setpoint = ");
  Serial.println(MainSetPoint, DEC);
  Serial.print("Main Temp = ");
  Serial.println(ReadTempMain, DEC);
  Serial.print("Zone 1 Temp = ");
  Serial.println(MainSetPoint, DEC);ReadTempZone1)
  Serial.print("Selector = " Selector)
  
  
  //LEDPanel
  if (Cool = on) then (LED1 = on), (Serial.print("Cool System is ON.") else (LED1 = off), (Serial.print("Cool System is OFF.");
  if (Heat = on) then (LED2 = on), (Serial.print("Heat System is ON.") else (LED2 = off), (Serial.print("Heat System is OFF.");
  if (EmHeat = on) then (LED2 = flashing), (Serial.print("AUX Heat System is ON.") else (LED2 = off), (Serial.print("AUX Heat System is OFF.");
  if (Selector = SELFAULT) then (LED2 = flashing), (LED1 = flashing), (Serial.print("Unable To Determine System State, Check Selector Switch.");
  if (FanON = True) then (LED1 = flashing), (Serial.print("FAN is ON.") else (LED1 = off), (Serial.print("FAN is OFF.");
  
  
}

I am trying to compile my code, but I keep getting these four errors:

sketch_nov25a:15: error: 'angle' was not declared in this scope
sketch_nov25a:16: error: 'angle' was not declared in this scope
sketch_nov25a:148: error: redefinition of 'int AdjDamper1'
sketch_nov25a:15: error: 'int AdjDamper1' previously defined here

I cannot seem to figure out why this is happening.

I am definitely declaring angle in my program (int angle = 0;)
The lines that the error output refers to, 15 and 16, can have nothing at all to do with the program. I can add spacing in the beginning of the program, and it still says lines 15 and 16 are at fault even though they are blank.

I have also made sure that I am not defining AdjDamper1 twice in my program, yet the console output says otherwise.

I've tried copying and pasting the code into a new window, thinking that perhaps the file became corrupt, but its still erroring out.

What am I doing wrong?

Any help would be greatly appreciated.

Once again, I remind you all that I am very new at coding, so please excuse any glaring errors - I barely have any idea what I am doing.

You have defined variable int angle and than you defined a function with same name as parameter, not really specifying the parameter type. .
The compiler does not like it.

try
variable function ( variable name)

such as
int function (int Angle) or void function....
{
if( Angle)
{
.....

and call the function

function (angle);

Cheers
Vaclav

Your running foul of the Arduino preprocessor. C/C++ requires that you declare functions before they are used. One of the things it "helpfully" does for you is to add proto types of your functions to get you round this rule. These are just coies of the start of your function declarations eg int AdjDamper2(iangle);

But in your case your dec is in correct as angle needs a type.

Which ends up with the compiler reporting errors in very strange places.

Mark

Thanks everyone,
I fixed it.

Now to deal with the new errors....

I think I can handle this from here out.