#include <LiquidCrystal_I2C.h>
#include <Servo.h>
#define servo 2
Servo serv;
#define btn 3
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
pinMode(btn, INPUT_PULLUP);
lcd.init();
lcd.backlight();
serv.attach(2);
}
void loop() {
int butt = digitalRead(3);
int lux = analogRead(A1);
int pot = analogRead(A0);
int ugol = map(pot, 0, 180, 0, 100);
const float BETA = 3950;
int analogValue = analogRead(A2);
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
static uint32_t tmr;
if(millis() - tmr >= 500){
tmr = millis();
lcd.clear();
lcd.home();
lcd.print(analogValue);
lcd.setCursor(0,1);
lcd.print(ugol);
}
if(!butt == 1) {
static uint32_t tmr;
if(millis() - tmr >= 500){
tmr = millis();
lcd.clear();
lcd.home();
lcd.print(celsius);
}
}
if(pot == 0 && lux < 150) {
serv.write(0);
}
if(pot == 0 && lux > 150) {
serv.write(0);
}
}