Hardware Reference
In-Depth Information
while(Wire.available() == 0); //Wait for response
int c = Wire.read(); //Get the temp in C
lcd.setCursor(8,0); //Move the cursor
lcd.print(c); //Print this new value
//Debounce both buttons
currentDownTempButton = debounce(lastDownTempButton, DOWN_BUTTON);
currentUpTempButton = debounce(lastUpTempButton, UP_BUTTON);
//Turn down the set temp
if (lastDownTempButton== LOW && currentDownTempButton == HIGH)
{
set_temp--;
}
//Turn up the set temp
else if (lastUpTempButton== LOW && currentUpTempButton == HIGH)
{
set_temp++;
}
//Print the set temp
lcd.setCursor(8,1);
lcd.print(set_temp);
lastDownTempButton = currentDownTempButton;
lastUpTempButton = currentUpTempButton;
//It's too hot!
if (c >= set_temp)
{
//So that the speaker will only beep one time...
if (!one_time)
{
tone(SPEAKER, 400);
delay(500);
one_time = true;
}
//Turn off the speaker if it's done
else
{
noTone(SPEAKER);
}
//Turn the fan on and update display
digitalWrite(FAN, HIGH);
lcd.setCursor(15,1);
lcd.write(2);
}
//It't not to hot!
else
{
//Make sure the speaker is off, reset the "one beep" variable
//Update the fan state, and LCD display
noTone(SPEAKER);
Search WWH ::




Custom Search