Hello, I am sorry for my absence.
Thanks everyone for help with menu.
I need this menu to bulid steering of kettle. I want to measure temperature and activate pump. I try to do this in code below. I use sensor DS18B20 and LED on pin 52. In egz wen temp is over 25deg pin 52 is high. I cant place this part of code to void loop because is generate error: tempC is not declared in this scope. When I place it into void setup is working good.
What I do wrong?
Thank you for help.
code:
if (tempC >= 25.00)
{
digitalWrite(52, HIGH);
}
else
{
digitalWrite(52, LOW);
}
code:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
#define ONE_WIRE_BUS 22
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer = { 0x28, 0x26, 0x44, 0xBB, 0x03, 0x00, 0x00, 0x0D };
void setup(void)
{
Serial.begin(9600);
pinMode(52, OUTPUT);
sensors.begin();
sensors.setResolution(insideThermometer, 10);
lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
lcd.clear(); // start with a blank screen
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
lcd.print("Error");
}
else {
lcd.print(tempC);
}
}
void loop(void)
{
delay(2000);
sensors.requestTemperatures();
lcd.setCursor(0,0);
lcd.print("kociol: ");
printTemperature(insideThermometer);
lcd.write(0xDF);
lcd.write('C');
}