51 lines
909 B
C++
51 lines
909 B
C++
#include <LiquidCrystal_I2C.h>
|
|
|
|
LiquidCrystal_I2C lcd(0x3F,20,4);
|
|
|
|
void setup() {
|
|
pinMode(2, OUTPUT);
|
|
pinMode(3, INPUT_PULLUP);
|
|
|
|
digitalWrite(2, LOW);
|
|
|
|
lcd.init(); // initialize the lcd
|
|
// Print a message to the LCD.
|
|
lcd.backlight();
|
|
lcd.setCursor(6,0);
|
|
lcd.print("Auto Cooker");
|
|
lcd.setCursor(1,1);
|
|
lcd.print("By Yannis Gerlach");
|
|
|
|
delay(1000);
|
|
|
|
updateLCD();
|
|
}
|
|
|
|
bool heating = false;
|
|
void updateLCD() {
|
|
lcd.clear();
|
|
lcd.clear();
|
|
lcd.setCursor(0,0);
|
|
lcd.print("Heater:");
|
|
lcd.setCursor(15,0);
|
|
lcd.print(heating ? "ON" : "OFF");
|
|
}
|
|
|
|
bool presed = false;
|
|
void loop() {
|
|
delay(25);
|
|
if(digitalRead(3) == LOW) {
|
|
if(!presed) {
|
|
presed = true;
|
|
//toggle
|
|
|
|
heating = !heating;
|
|
digitalWrite(2, heating);
|
|
digitalWrite(13, heating);
|
|
updateLCD();
|
|
}
|
|
} else {
|
|
presed = false;
|
|
}
|
|
}
|