EasyManua.ls Logo

SunFounder 3in1 Kit - Page 210

Default Icon
351 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SunFounder 3in1 Kit
(continued from previous page)
lcd.print("Upper Tem: ");
while (1) {
lcd.setCursor(11, 1);
setTem = map(analogRead(potPin), 0, 1023, 0, 100);
lcd.print(setTem);
if (state == 0)
{
EEPROM.write(0, setTem);
upperTem = setTem;
lcd.clear();
return;
}
}
}
A threshold can be set with this function. When you enter this function, the LCD1602 displays
the current threshold value, which can be modified using the potentiometer. This threshold value
will be stored in EEPROM and exited when the button is pressed again.
4. About monitoringTemp() function.
void monitoringTemp()
{
long a = analogRead(temPin);
float tempC = beta / (log((1025.0 * 10 / a - 10) / 10) + beta / 298.0) -
˓273.0;
float tempF = 1.8 * tempC + 32.0;
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(tempC);
lcd.print(char(223));
lcd.print("C ");
lcd.setCursor(0, 1);
lcd.print("Upper: ");
lcd.print(upperTem);
lcd.print(char(223));
lcd.print("C ");
delay(300);
if (tempC >= upperTem)
{
digitalWrite(buzzerPin, HIGH);
delay(50);
digitalWrite(buzzerPin, LOW);
delay(10);
}
else
{
digitalWrite(buzzerPin, LOW);
}
}
Using this function, you can display temperature and set an alarm.
206 Chapter 4. Basic Projects

Related product manuals