system
April 17, 2012, 10:55pm
16
You leave an if statement by "falling off the end". Here's a quick and dirty re-write of what I think you're trying to do:
#define BUTTON ?
#define SENSOR ?
#define MAXT 74
#define MINT 70
int temperature; /* Temperature reading */
void fix_hi_temp(int t) /* Correct over-temperature */
{
}
void fix_lo_temp(int t) /* Correct under-temperature */
{
}
void setup()
{ Serial.begin(115200); /* Connect monitor */
pinMode(BUTTON,INPUT);
}
void loop()
{ temperature = analogRead(SENSOR); /* Read temp */
if (temperature > MAXT)
{ Serial.println("Temp too high"); /* Display the error */
if (digitalRead(BUTTON) == HIGH) fix_hi_temp();
}
else if (temperature < MINT)
{ Serial.println("Temp too low"); /* Display the error */
if (digitalRead(BUTTON) == HIGH) fix_lo_temp();
}
}
I like this idea alot.. I'm going to try a crack at this instead of the complicated way of writing like mine is.
I just feel like its easy to get lost in my code..
Isnt this format called "Subroutines"?