/*
We need your help to stop forest fires and bake tasty cookies!
See `requirements.md` for how to help.
Then check `notes.md`.
*/
#include "api.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,10,9,8,6);
bool gasvalvestate=false ;
bool prevgasvalvestate=false ;
void setup() {
Serial.begin(115200);
setup_api();
Serial.println("Elf oven 2000 starting up.");
serial_printf("Days without fire incident: %i\n", 0);
lcd.begin(16,2);
lcd.print("Temperature");
}
void door_sensor_interrupt_handler(bool voltage_high)
{
// TODO: implement
}
void loop() {
// Some example code below to help show how to use API.
// Please delete it and replace with your own code.
uint16_t sensor_voltage = read_voltage(TEMPERATURE_SENSOR);
uint16_t vref_voltage = read_voltage(TEMPERATURE_SENSOR_REFERENCE) + 4500;
serial_printf("vref_voltage : %i mV\n", vref_voltage);
serial_printf("sensor_voltage : %i mV\n", sensor_voltage);
uint16_t temperatureC = map( sensor_voltage, 0.1*vref_voltage , 0.9*vref_voltage, -10.0, 300.0);
serial_printf("Temperature %i °C\n", temperatureC);
set_output(GAS_VALVE, temperatureC < 160);
if (digitalRead(3)== HIGH) {
digitalWrite(4, HIGH);
}
gasvalvestate=digitalRead(2);
if (gasvalvestate && !prevgasvalvestate) {
digitalWrite (7, HIGH);
delay (5000);
digitalWrite (7, LOW);
}
prevgasvalvestate=gasvalvestate;
delay(1000); // feel free to change. What would you use for an actual iteration period?
}