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)