experienced hand to find a problem

I have a program that runs quite well and does everything i want (much borrowed and begged) So decided to add some extra functionality using a potentiometer via analog input, and storing the value in eeprom.
After testing out a some trial code, which appeared to work, i added the code to my program. first of all there were a few errors to deal with but the more i fiddled the more it became apparent that i dont know what im looking at.

the error (at first) evolved around variable TTL (int) and (at first) produced few errors. I changed the name of TTL (dont really know why) but produced the same result.

When i commented out and changed any reference to TTL the code uploads (untested as yet). So im pretty sure its this variable.

it may be glaringly obvious here...

void settings() {
  int DTMF = checkDTMF();
  if  (DTMF == 7 && digitalRead(setPin) == 1){
    hrs();
  }
  if  (DTMF == 3 && digitalRead(setPin) == 1){
    ttl();
   }
  void hrs() {
    v(24); delay(1000);           // "off"
    v(39); delay(1000);           // "set"
    v(43); delay(2000);            // "hours"
    int HRS = MIN * 2 / 60;
    String a;
    a = String(HRS);
    char fd = a.charAt(0);
    v(fd); delay(800);
    char sd = a.charAt(1);
    v(sd); delay(800);
    char td = a.charAt(2);
    v(td); delay(800);
    v(43); delay(1000);       //hours
    v(21); delay(1000);       //press
    v(9);  delay(800);        //nine
    v(2);  delay(800);        //to
    v(22); delay(2000);       //confirm
    if (DTMF == 9 && digitalRead(setPin) == 1) {
      while (!eeprom_is_ready()) {
        cli();
        eeprom_write_word((uint16_t*)ADP, 0);
        sei();
      v(39); delay(1000);     //set
      v(25); delay(1500);     //restarting
      simc.println("ATH");  //hang up
      loop();
    }
  }hrs();
  }
  void ttl() {
    v(30); delay(1000);           // "temperature"
    v(38); delay(1000);           // "threshold"
    v(20); delay(800);            // "low"

    int b = analogRead(A3);
    TTL = map(b, 0, 1023, -10, 30);
    String a;
    a = String(TTL);
    if (a.startsWith("-")) {
      v(45); delay (1500);
      char fd = a.charAt(1);
      v(fd); delay(800);
      char sd = a.charAt(2);
      v(sd); delay(800);
    }
    else {
      char fd = a.charAt(0);
      v(fd); delay(800);
      char sd = a.charAt(1);
      v(sd); delay(800);
    }
    v(33); delay(1000);       //degrees
    v(21); delay(1000);       //press
    v(9);  delay(800);        //nine
    v(2);  delay(800);        //to
    v(22); delay(2000);       //confirm
    if (DTMF == 9 && digitalRead(setPin) == 1) {
      while (!eeprom_is_ready())
        cli();
      eeprom_write_word((uint16_t*)0, TTL);
      sei();
      v(39); delay(1000);
      tth();
    }
  }ttl();
}
void tth() {
  int DTMF = checkDTMF();
  v(30); delay(1000);           // "temperature"
  v(38); delay(1000);           // "threshold"
  v(40); delay(800);            // "high"
  int b = analogRead(A3);
  TTH = map(b, 0, 1023, 0, 99);
  String a;
  a = String(TTH);
  if (a.startsWith("-")) {
    v(45); delay (1500);
    char fd = a.charAt(1);
    v(fd); delay(800);
    char sd = a.charAt(2);
    v(sd); delay(800);
  }
  else {
    char fd = a.charAt(0);
    v(fd); delay(800);
    char sd = a.charAt(1);
    v(sd); delay(800);
  }
  v(33); delay(1000);       //degrees
  v(21); delay(1000);       //press
  v(9);  delay(800);        //nine
  v(2);  delay(800);        //to
  v(22); delay(2000);       //confirm
  if (DTMF == 9 && digitalRead(setPin) == 1) {
    while (!eeprom_is_ready()) {
      cli();
      eeprom_write_word((uint16_t*)2, TTH);
      sei();
      v(39); delay(1000);
      ttc();
    }
  }tth();
}
void ttc() {
  int DTMF = checkDTMF();
  v(29); delay(1000);           // "cold"
  v(30); delay(1000);           // "temperature"
  v(35); delay(800);            // "waiting"
  int b = analogRead(A3);
  TTC = map(b, 1023, 0, TTL, -30);
  String a;
  a = String(TTC);
  if (a.startsWith("-")) {
    v(45); delay (1500);
    char fd = a.charAt(1);
    v(fd); delay(800);
    char sd = a.charAt(2);
    v(sd); delay(800);
  }
  else {
    char fd = a.charAt(0);
    v(fd); delay(800);
    char sd = a.charAt(1);
    v(sd); delay(800);
  }
  v(33); delay(1000);       //degrees
  v(21); delay(1000);       //press
  v(9);  delay(800);        //nine
  v(2);  delay(800);        //to
  v(22); delay(2000);       //confirm
  if (DTMF == 9 && digitalRead(setPin) == 1) {
    while (!eeprom_is_ready()) {
      cli();
      eeprom_write_word((uint16_t*)4, TTC);
      sei();
      v(39); delay(1000);
      cdr();
    }
  }ttc();
}
void cdr() {
  int DTMF = checkDTMF();
  v(29); delay(1000);           // "cold"
  v(30); delay(1000);           // "temperature"
  v(35); delay(1000);            // "waiting"
  int b = analogRead(A3);
  int CDR = map(b, 0, 1023, 1, 99000);
  String a;
  a = String(CDR);
  char fd = a.charAt(0);
  v(fd); delay(800);
  char sd = a.charAt(1);
  v(sd); delay(800);
  v(41); delay(1000);       //milliSeconds
  v(21); delay(1000);       //press
  v(9);  delay(800);        //nine
  v(2);  delay(800);        //to
  v(22); delay(2000);       //confirm
  if (DTMF == 9 && digitalRead(setPin) == 1) {
    while (!eeprom_is_ready()) {
      cli();
      eeprom_write_word((uint16_t*)6, CDR);
      sei();
      v(39); delay(1000);
      mcd();
    }
  }cdr();
}
void mcd() {
  int DTMF = checkDTMF();
  v(42); delay(1000);           // "cranking"
  v(32); delay(1000);           // "timeout"
  int b = analogRead(A3);
  MCD = map(b, 0, 1023, 600, 6000);
  String a;
  a = String(MCD);
  char fd = a.charAt(0);
  v(fd); delay(800);
  char sd = a.charAt(1);
  v(sd); delay(800);
  v(41); delay(1000);       //seconds
  v(21); delay(1000);       //press
  v(9);  delay(800);        //nine
  v(2);  delay(800);        //to
  v(22); delay(2000);       //confirm
  if (DTMF == 9 && digitalRead(setPin) == 1) {
    while (!eeprom_is_ready()) {
      cli();
      eeprom_write_word((uint16_t*)8, MCD);
      sei();
      v(39); delay(1000);
      cyl();
    }
  }mcd();
}
void cyl() {
  int DTMF = checkDTMF();
  v(15); delay(1000);           // "engine"
  v(30); delay(1000);           // "temperature"
  v(40); delay(800);            // "high"
  int b = analogRead(A3);
  CYL = map(b, 0, 1023, 70, 126);
  String a;
  a = String(CYL);
  char fd = a.charAt(0);
  v(fd); delay(800);
  char sd = a.charAt(1);
  v(sd); delay(800);
  char td = a.charAt(2);
  v(td); delay(800);
  v(33); delay(1000);       //degrees
  v(21); delay(1000);       //press
  v(9);  delay(800);        //nine
  v(2);  delay(800);        //to
  v(22); delay(2000);       //confirm
  if (DTMF == 9 && digitalRead(setPin) == 1) {
    while (!eeprom_is_ready()) {
      cli();
      eeprom_write_word((uint16_t*)10, CYL);
      sei();
      v(39); delay(1000);     //set
      v(25); delay(1500);     //restarting
      simc.println("ATH");  //hang up
      loop();
    }
  }cyl();
}

attached is the full code.

Thanks for taking a look

gimpyDip.ino (52.7 KB)

Do you want to be a little less vague, and tell us what errors you were seeing?

That's weird. I guess you've confused the IDE and it's breaking something when it tries to munge your code into a compilable program.

It compiles for me if I move the declaration of TTA up above the comment the line above its current position.

errors:

C:\Users\Andrew\Desktop\gimpyDip\gimpyDip.ino: In function 'void setup()':

gimpyDip:98:3: error: 'TTL' was not declared in this scope

   TTL = eeprom_read_word((uint16_t*)0);

   ^~~

C:\Users\Andrew\Desktop\gimpyDip\gimpyDip.ino:98:3: note: suggested alternative: 'TTC'

   TTL = eeprom_read_word((uint16_t*)0);

   ^~~

   TTC

C:\Users\Andrew\Desktop\gimpyDip\gimpyDip.ino: In function 'void disengage_starter()':

gimpyDip:441:14: error: 'TTL' was not declared in this scope

   if (val >= TTL) {                                                                                                           // if temp >= temp threshold LOW

              ^~~

C:\Users\Andrew\Desktop\gimpyDip\gimpyDip.ino:441:14: note: suggested alternative: 'TTC'

   if (val >= TTL) {                                                                                                           // if temp >= temp threshold LOW

              ^~~

              TTC

C:\Users\Andrew\Desktop\gimpyDip\gimpyDip.ino: In function 'void settings()':

gimpyDip:679:5: error: 'hrs' was not declared in this scope

     hrs();

     ^~~

gimpyDip:682:5: error: 'ttl' was not declared in this scope

     ttl();

     ^~~

C:\Users\Andrew\Desktop\gimpyDip\gimpyDip.ino:682:5: note: suggested alternative: 'ttc'

     ttl();

     ^~~

     ttc

gimpyDip:684:14: error: a function-definition is not allowed here before '{' token

  [u][/u] void hrs() {

              ^

gimpyDip:714:14: error: a function-definition is not allowed here before '{' token

   void ttl() {

              ^

gimpyDip:749:4: error: 'ttl' was not declared in this scope

   }ttl();

    ^~~

C:\Users\Andrew\Desktop\gimpyDip\gimpyDip.ino:749:4: note: suggested alternative: 'ttc'

   }ttl();

    ^~~

    ttc

C:\Users\Andrew\Desktop\gimpyDip\gimpyDip.ino: In function 'void ttc()':

gimpyDip:794:25: error: 'TTL' was not declared in this scope

   TTC = map(b, 1023, 0, TTL, -30);

                         ^~~

C:\Users\Andrew\Desktop\gimpyDip\gimpyDip.ino:794:25: note: suggested alternative: 'TTC'

   TTC = map(b, 1023, 0, TTL, -30);

                         ^~~

                         TTC

Using library SoftwareSerial at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial 
Using library OneWire at version 2.3.4 in folder: C:\Users\Andrew\Documents\Arduino\libraries\OneWire 
Using library DallasTemperature at version 3.8.0 in folder: C:\Users\Andrew\Documents\Arduino\libraries\DallasTemperature 
exit status 1
'TTL' was not declared in this scope

TheMemberFormerlyKnownAsAWOL:

TheMemberFormerlyKnownAsAWOL:
Do you want to be a little less vague, and tell us what errors you were seeing?

sorry have now posted

wildbill:
That's weird. I guess you've confused the IDE and it's breaking something when it tries to munge your code into a compilable program.

It compiles for me if I move the declaration of TTA up above the comment the line above its current position.

I tried moving the declaration further down between the others and at the bottom of the list, Ill try your method soon - thanks

Open your sketch and use Tools/Autoformat.
check whether the "}" at the end of each function are at first column. If not, you missed one or more of them or you have more than nececery "{"

GRuser:
Open your sketch and use Tools/Autoformat.
check whether the "}" at the end of each function are at first column. If not, you missed one or more of them or you have more than nececery "{"

done that and although you are right, it did point out some braces in the wrong place, its come back with even more errors!

could it be that I am using the same (local) variables in subsequent functions?

That's weird. I guess you've confused the IDE and it's breaking something when it tries to munge your code into a compilable program.

It compiles for me if I move the declaration of TTA up above the comment the line above its current position.
[/quote]

Can i ask which IDE your running please

1.6.12

Problem solved guys thanks for your help

GRuser:
Open your sketch and use Tools/Autoformat.
check whether the "}" at the end of each function are at first column. If not, you missed one or more of them or you have more than nececery "{"

Your advice didnt directly solve my problem but it may have helped, It certainly saved me hours if not days and something i never thought to do before. Cheers

wildbill:
That's weird. I guess you've confused the IDE and it's breaking something when it tries to munge your code into a compilable program.

It compiles for me if I move the declaration of TTA up above the comment the line above its current position.

The problem wasn't the code it was my use of the backslash:

#include <avr/eeprom.h>                                       // and eeprom features  
/////////////////////////////////EEPROM VARS\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
int TTL;
int TTH;

How it is a backslash i do not know as i dont remember using them! What give it away was deleting the EEPROM VARS comment line and the int of TTL variable was flashing blue/grey, so any odd backslashes resulted in TTL being commented out on the following line!

Thought the double forward slash would have cancelled anything else on that line!

is this a known issue or is the backslash some kind of special function?

ANyways thank you all for your help

Backslash is “line continuation “, even for comments.

westfw:
Backslash is “line continuation “, even for comments.

from what i know about c, i do not believe i will be using that. thanks for your advice