// Info Fat 1
char name1[]="1 - Bohemen";
char type1[]="Pilsner";
char abv1[]="5,9%";
char litertext[]="Liter igjen";
char fattext[]="Fat-dato: 01.01.2001";
char name2[]="2 - Flamingofest";
char type2[]="American IPA";
char abv2[]="6,0%";
char fattext2[]="Fat-dato: 01.01.1974";
char rensdate1[]="1-Renset 12.12.2012";
char rensdate2[]="1-Renset 12.12.2022";
char co2date[]= "Ny Co2 03.03.2003";
#include <LiquidCrystal.h>
#include <HX711.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 8
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
int inPin = 2; // the number of the input pin
int outPin = 13; // the number of the output pin
//Vekt
#define CLK1 A1 // connections for the Weight sensors
#define DOUT1 A0
#define CLK2 A3
#define DOUT2 A2
#define zero_factor_1 0 // scale 1 offset. This value is obtained by using the Calibration sketch
#define zero_factor_2 0 // scale 2 offset. This value is obtained by using the Calibration sketch
#define calibration_factor_1 2125 // Calibration factor, This value is obtained using the Calibration sketch
#define calibration_factor_2 2125
HX711 scale1; // get an instance
HX711 scale2; // get another instance
#define Keg1_Weight 4.33 // empty keg 1 weight ************************TO DO *********************************
#define Keg2_Weight 4.88 // empty keg 2 weight
//Button
int state = HIGH; // the current state of the output pin
int reading; // the current reading from the input pin
int previous = LOW; // the previous reading from the input pin
unsigned long time = 0; // the last time the output pin was toggled
unsigned long debounce = 200UL; // the debounce time, increase if the output flickers
int textState;
//Screen
const int rs = 12, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void ScreenDraw1(){
lcd.begin(20, 4);
lcd.setCursor(04, 0);
lcd.print("FLORENVEIEN");
lcd.setCursor(05, 1);
lcd.print("BRYGGERIER");
lcd.setCursor(02, 3);
lcd.print("Temperatur");
lcd.setCursor(14, 3);
lcd.print(sensors.getTempCByIndex(0));
delay(3500);
lcd.clear();
lcd.setCursor(02, 0);
lcd.print("Trykk og hold for");
lcd.setCursor(01, 1);
lcd.print("oversikt over dato");
lcd.setCursor(03, 2);
lcd.print("for siste rens");
}
void screenDraw2(){
lcd.begin(20, 4);
lcd.print(name1);
lcd.setCursor(0, 1);
lcd.print(type1);
lcd.setCursor(15, 1);
lcd.print(abv1);
lcd.setCursor(0, 2);
lcd.print(litertext);
lcd.setCursor(0, 3);
lcd.print(fattext);
}
void screenDraw3(){
lcd.begin(20, 4);
lcd.print(name2);
lcd.setCursor(0, 1);
lcd.print(type2);
lcd.setCursor(15, 1);
lcd.print(abv2);
lcd.setCursor(0, 2);
lcd.print(litertext);
lcd.setCursor(0, 3);
lcd.print(fattext2);
}
void screenDraw4(){
lcd.begin(20, 4);
lcd.print(rensdate1);
lcd.setCursor(0, 1);
lcd.print(rensdate2);
lcd.setCursor(0, 3);
lcd.print(co2date);
}
void setup()
{sensors.begin();
sensors.requestTemperatures();
pinMode(inPin, INPUT);
pinMode(outPin, OUTPUT);
scale1.begin(DOUT1, CLK1);
scale2.begin(DOUT2, CLK2);
scale1.set_scale(calibration_factor_1); // This value is obtained by using the Calibration sketch
scale2.set_scale(calibration_factor_2); // NO Tare in case of power failure or reset
scale1.set_offset(zero_factor_1);
scale2.set_offset(zero_factor_2);
ScreenDraw1();
delay(3000);
reading = digitalRead(inPin);
// if the input just went from LOW and HIGH and we've waited long enough
// to ignore any noise on the circuit, toggle the output pin and remember
// the time
if (reading == HIGH)
{
screenDraw4();
delay(7000);
}
screenDraw2();
reading = HIGH;
textState=HIGH;
}
void loop()
{
reading = digitalRead(inPin);
// if the input just went from LOW and HIGH and we've waited long enough
// to ignore any noise on the circuit, toggle the output pin and remember
// the time
if (reading == HIGH && previous == LOW && millis() - time > debounce)
{
if (state == HIGH){
state = LOW;
textState=LOW;
}
else{
state = HIGH;
textState=HIGH;
}
time = millis();
}
digitalWrite(outPin, state);
if (textState == HIGH){
if (previous != reading){
// set up the LCD's number of columns and rows:
screenDraw2();
}
lcd.setCursor(15, 2);
lcd.print(scale1.get_units() - Keg1_Weight, 1);
}
else{
if (previous != reading){
screenDraw3();}
lcd.setCursor(15, 2);
lcd.print(scale2.get_units() - Keg2_Weight, 1);
}
previous = reading;
}