#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip
// LCD geometry
const int LCD_COLS = 16;
const int buttonPin = 13; // the number of the button pin
const int switch1Pin = 11; // the number of the switch1 pin
const int switch2Pin = 12; // the number of the switch2 pin
const int motorPin = 6; // the number of the motor pin
const int LED = 8; // light up the blue led
int buttonState = 0; // variable for reading the button's status
int switch1State = 0; // variable for reading the switch1 status
int switch2State = 0; // variable for reading the switch2 status
const int motorPin2 = 7; // the number of the motor pin
int i = 1; //Holds the value for the menu
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);// set up the number of columns and rows on the LCD
lcd.print(" LITTLE BEER");
lcd.setCursor(0,1);
lcd.print(" DISPENSER");
// initialize the inputs and outputs
// initialize the motor pin as an output:
pinMode(motorPin, OUTPUT);
pinMode(motorPin2, OUTPUT);
// initialize the switch pin as an input:
pinMode(buttonPin, INPUT);
pinMode(LED, OUTPUT);
Serial.begin(6000);
delay(5000);
}
void loop() {
// read the state of the switch1 and switch2 value:
switch1State = digitalRead(switch1Pin);
switch2State = digitalRead(switch2Pin); {
if (switch1State == HIGH) {
// enter liquor 43 purge/clean mode:
// read the state of the button value:
buttonState = digitalRead(buttonPin); {
if (buttonState == HIGH) {
// turn motor on:
lcd.clear();
lcd.print("PURGING");
lcd.setCursor(0,1);
lcd.print("LIQUOR 43...");
digitalWrite(motorPin, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(LED, HIGH);
delay(500);
}
else {
digitalWrite(motorPin, LOW);
digitalWrite(motorPin2, LOW);
lcd.clear();
lcd.print("*LIQUOR43 PURGE*");
lcd.setCursor(0,1);
lcd.print(" PRESS BUTTON");
digitalWrite(LED, HIGH);
delay(100);
digitalWrite(LED, LOW);
delay(200);
}
}
}
else if (switch2State == HIGH) {
// enter cream purge/clean mode:
// read the state of the button value:
buttonState = digitalRead(buttonPin); {
if (buttonState == HIGH) {
// turn motor on:
lcd.clear();
lcd.print("PURGING");
lcd.setCursor(0,1);
lcd.print("CREAM...");
digitalWrite(motorPin, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(LED, HIGH);
delay(500);
}
else {
digitalWrite(motorPin, LOW);
digitalWrite(motorPin2, LOW);
lcd.clear();
lcd.print(" *CREAM PURGE*");
lcd.setCursor(0,1);
lcd.print(" PRESS BUTTON");
digitalWrite(LED, HIGH);
delay(100);
digitalWrite(LED, LOW);
delay(200);
}
}
}
else {
// read the state of the button value:
lcd.clear();
lcd.print("PRESS BUTTON");
lcd.setCursor(0,1);
lcd.print("TO DISPENSE...");
delay(500);
buttonState = digitalRead(buttonPin); {
if (buttonState == HIGH) {
// turn motor on:
lcd.clear();
lcd.print("DISPENSING IN 3");
delay(1000);
lcd.clear();
lcd.print("DISPENSING IN 2");
delay(1000);
lcd.clear();
lcd.print("DISPENSING IN 1");
delay(1000);
lcd.clear();
lcd.print("DISPENSING");
lcd.setCursor(0,1);
lcd.print("LIQUOR 43...");
digitalWrite(motorPin, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(LED, HIGH);
delay(10000); // liquor 43 control amount
lcd.clear();
lcd.print("DISPENSING");
lcd.setCursor(0,1);
lcd.print("HEAVY CREAM...");
digitalWrite(motorPin, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(LED, HIGH);
delay(4000); // heavy cream control amount
digitalWrite(motorPin, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(LED, HIGH);
lcd.clear();
lcd.print("LITTLE BEERS!!!!!");
delay(7000);
lcd.clear();
lcd.print("READY FOR MORE?");
lcd.setCursor(0,1);
lcd.print("PUSH THE BUTTON!");
}
else {
// turn motor off:
digitalWrite(motorPin, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(LED, HIGH);
}
}
}
}
}