/*
The goal is the dial in the best cup of coffee.
Have fun and enjoy the process
Maker Aaron Beaver
@aaronbeaver
@coffeesnobspodcast
*/
#include <SPI.h>
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
// Keypad //
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
/*
// REAL //
char keys[ROWS][COLS] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte rowPins[ROWS] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 7, 8}; //connect to the column pinouts of the keypad
*/
// WEB //
char keys[ROWS][COLS] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
// Keypad //
// LCD //
LiquidCrystal_I2C lcd(0x27, 20, 4); // set the LCD address to 0x27 for a 16 chars and 2 line display
// LCD //
// variables //
int IN1 = 12;
int IN2 = 13;
int inputInt = 0;
int IntCountA = 0;
String inputString;
String inputStringA;
String inputStringB;
String inputStringC;
String inputStringD;
long GrindAmount = 15; // base amount
long WaterRatio = 17; // base amount
long BrewAmount = 255; // base amount
long inputIntD = 0;
boolean Step1 = true;
boolean Step2 = false;
boolean Step3 = false;
boolean Step4 = false;
boolean Step5 = false;
boolean Step6 = false;
float pourml1; // pour amount in milliliters
float pourml2; // pour amount in milliliters
float poursec1; // pour amount in seconds
float poursec2; // pour amount in seconds
float pourmill1; // pour amount in milliseconds
float pourmill2; // pour amount in milliseconds
float pour1;
float pour2;
float pour3;
float pour4;
float pour5;
float pour6;
//
int brew1 = 2000; // wait time between pump on
int brew2 = 10000; // wait time between pump on
int brew3 = 10000; // wait time between pump on
int brew4 = 10000; // wait time between pump on
int brew5 = 10000; // wait time between pump on
//
float dripratio1 = .235; // 23% on bloom pour
float dripratio2 = .19125; // 19% on next 4 pours
//
float pourrate1 = .235; // 23% on bloom pour
float pourrate2 = .176; // 17% on bloom pour
float pourrate3 = .205; // 20% on next 4 pours
//
float pumprate = 9.84; // milliliter’s per sec
int waittime = 1000; // milliseconds
int button;
int brew = 0;
char key;
// variables //
#define BACKLIGHT_PIN 3
void setup() {
Serial.begin(9600);
lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
lcd.backlight();
//message//
lcd.setCursor(8, 0);
lcd.print("Hello");
lcd.setCursor(5, 1);
lcd.print("Coffee Snob!");
lcd.scrollDisplayLeft();
delay(200); // wait
lcd.setCursor(2, 2);
lcd.print("Lets make a great");
lcd.setCursor(4, 3);
lcd.print("Cup of Coffee");
delay(200); // wait
lcd.clear();
//message//
lcd.setCursor(0, 0);
lcd.print("How much coffee");
lcd.setCursor(0, 1);
lcd.print("did you grind?");
lcd.setCursor(0, 3);
lcd.print("# Enter || * Reset");
//BrewStep1();
//bootup();
// prime pump start//
pinMode(IN1, OUTPUT);
digitalWrite(IN1, HIGH);
digitalWrite(IN1, LOW);
delay(250);
digitalWrite(IN1, HIGH);
// prime pump end//
}
void loop() {
key = keypad.getKey();
if (key >= '0' && key <= '9')// only act on numeric keys
{
inputString += key; // append new character to input string
lcd.setCursor(0, 2);
lcd.print(inputString);
}
else if (key == '#') {
if (Step5) { //IntCountA = IntCountA +1;
// START Pour 1 //
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Step 1");
lcd.setCursor(0, 1);
lcd.print("Pour Time:");
lcd.print(poursec1);
lcd.print("sec");
lcd.setCursor(0, 2);
lcd.print("Pour Amount:");
lcd.print(pourml1);
lcd.print("ML");
digitalWrite(IN1, LOW);
delay(pourmill1); // wait
// Ending Pour 1 //
// brew //
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("brew");
digitalWrite(IN1, HIGH);
delay(brew1); // wait
// brew //
// START Pour 2 //
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Step 2");
lcd.setCursor(0, 1);
lcd.print("Pour Time:");
lcd.print(poursec2);
lcd.print("sec");
lcd.setCursor(0, 2);
lcd.print("Pour Amount:");
lcd.print(pourml2);
lcd.print("ML");
pour1 = (pourml1 + pourml2);
lcd.setCursor(0, 3);
lcd.print("Total ML:");
lcd.print(pour1);
lcd.print("ML");
digitalWrite(IN1, LOW);
delay(pourmill1); // wait
// Ending Pour 2 //
// brew //
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("brew");
digitalWrite(IN1, HIGH);
delay(brew1); // wait
// brew //
// START Pour 3 //
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Step 3");
lcd.setCursor(0, 1);
lcd.print("Pour Time:");
lcd.print(poursec2);
lcd.print("sec");
lcd.setCursor(0, 2);
lcd.print("Pour Amount:");
lcd.print(pourml2);
lcd.print("ML");
pour2 = (pour1 + pourml2);
lcd.setCursor(0, 3);
lcd.print("Total ML:");
lcd.print(pour2);
lcd.print("ML");
digitalWrite(IN1, LOW);
delay(pourmill1); // wait
// Ending Pour 3 //
// brew //
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("brew");
digitalWrite(IN1, HIGH);
delay(brew1); // wait
// brew //
// START Pour 4 //
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Step 4");
lcd.setCursor(0, 1);
lcd.print("Pour Time:");
lcd.print(poursec2);
lcd.print("sec");
lcd.setCursor(0, 2);
lcd.print("Pour Amount:");
lcd.print(pourml2);
lcd.print("ML");
pour3 = (pour2 + pourml2);
lcd.setCursor(0, 3);
lcd.print("Total ML:");
lcd.print(pour3);
lcd.print("ML");
digitalWrite(IN1, LOW);
delay(pourmill1); // wait
// Ending Pour 4 //
// brew //
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("brew");
digitalWrite(IN1, HIGH);
delay(brew1); // wait
// brew //
// START Pour 5 //
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Step 5");
lcd.setCursor(0, 1);
lcd.print("Pour Time:");
lcd.print(poursec2);
lcd.print("sec");
lcd.setCursor(0, 2);
lcd.print("Pour Amount:");
lcd.print(pourml2);
lcd.print("ML");
pour4 = (pour3 + pourml2);
lcd.setCursor(0, 3);
lcd.print("Total ML:");
lcd.print(pour4);
lcd.print("ML");
digitalWrite(IN1, LOW);
delay(pourmill1); // wait
// Ending Pour 2 //
digitalWrite(IN1, HIGH);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Enjoy!");
Step4 = false;
Step5 = true;
}
if (Step4) { //IntCountA = IntCountA +1;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Step 4");
lcd.display();
lcd.setCursor(0, 1);
// pour var 1
pourml1 = (dripratio1 * BrewAmount);
poursec1 = (pourml1 / pumprate);
pourmill1 = (poursec1 * waittime);
// pour var 2
pourml2 = (dripratio2 * BrewAmount);
poursec2 = (pourml2 / pumprate);
pourmill2 = (poursec2 * waittime);
// pour var 1
lcd.print("Bloom:");
lcd.print(pourmill1);
lcd.setCursor(0, 2);
lcd.print("Pour 2-5:");
lcd.print(pourmill1);
lcd.setCursor(0, 3);
//lcd.print();
//lcd.print("g");
//lcd.setCursor(0, 2);
//lcd.print("Brewing Ratios: 1/");
//lcd.print(WaterRatio);
//lcd.setCursor(0, 2);
//lcd.print("Brew Recipe: ");
//lcd.print(BrewAmount);
//lcd.print("ml");
lcd.display();
Step4 = false;
Step5 = true;
}
if (Step3) { //IntCountA = IntCountA +1;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Coffee Snob Recipe");
lcd.setCursor(0, 1);
BrewAmount = (GrindAmount * WaterRatio);
lcd.print("Coffee Setup: ");
lcd.print(GrindAmount);
lcd.print("g");
lcd.setCursor(0, 2);
lcd.print("Brewing Ratios: 1/");
lcd.print(WaterRatio);
lcd.setCursor(0, 3);
lcd.print("Brew Recipe: ");
lcd.print(BrewAmount);
lcd.print("ml");
// pour var 1
pourml1 = (dripratio1 * BrewAmount);
poursec1 = (pourml1 / pumprate);
pourmill1 = (poursec1 * waittime);
// pour var 2
pourml2 = (dripratio2 * BrewAmount);
poursec2 = (pourml2 / pumprate);
pourmill2 = (poursec2 * waittime);
// pour var 1
Step3 = false;
Step4 = false;
Step5 = true;
}
if (inputString.length() > 0) {
if (Step2) {
WaterRatio = inputString.toInt(); // YOU GOT AN INTEGER NUMBER
inputString = "";// clear input
Serial.println(WaterRatio);
lcd.setCursor(0, 2);
lcd.print("1/");
lcd.print(WaterRatio);
lcd.print("oz");
delay(1000); // wait
BrewAmount = (GrindAmount * WaterRatio);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Brew Recipe: ");
lcd.setCursor(0, 1);
lcd.print(GrindAmount);
lcd.print("g | 1/");
lcd.print(WaterRatio);
lcd.print(" | ");
lcd.print(BrewAmount);
lcd.print("ml");
lcd.setCursor(0, 3);
lcd.print("# BREW || * Reset");
// pour var 1
pourml1 = (dripratio1 * BrewAmount);
poursec1 = (pourml1 / pumprate);
pourmill1 = (poursec1 * waittime);
Serial.println(pourmill1);
// pour var 2
pourml2 = (dripratio2 * BrewAmount);
poursec2 = (pourml2 / pumprate);
pourmill2 = (poursec2 * waittime);
Serial.println(pourmill2);
// pour var 1
Step2 = false;
Step3 = false;
Step4 = false;
Step5 = true;
Serial.println(Step2);
Serial.println(Step3);
}
if (Step1) {
BrewStep1();
}
}
}
if (key == '*') {
Serial.println("Clear");
lcd.clear();
Step1 = true;
Step2 = false;
Step3 = false;
Step4 = false;
Step5 = false;
GrindAmount = 0;
WaterRatio = 0;
BrewAmount = 0;
bootup();
}
}
void bootup() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("How much coffee");
lcd.setCursor(0, 1);
lcd.print("did you grind?");
lcd.setCursor(0, 3);
lcd.print("# Enter | * Reset");
Step1 = true;
Step2 = false;
Step3 = false;
Step4 = false;
Step5 = false;
GrindAmount = 0;
WaterRatio = 0;
BrewAmount = 0;
Serial.print("bootup");
}
void BrewStep1(){
GrindAmount = inputString.toInt(); // YOU GOT AN INTEGER NUMBER
inputString = "";// clear input
Serial.println(GrindAmount);
lcd.setCursor(0, 2);
lcd.print(GrindAmount);
lcd.print("grams");
Step1 = false;
Step2 = true;
delay(1000); // wait
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("What is your");
lcd.setCursor(0, 1);
lcd.print("brew ratio?");
lcd.setCursor(0, 3);
lcd.print("# Enter || * Reset");
Serial.println(Step1);
Serial.println(Step2);
}