Had this idea a while back, decided to make it into a home project.
Started tinkering with the code already.
at the moment the requirements are:
Button to start the sequence
Button to pause & resume the sequence
One fuction to pre-soak the coffee for a set period of time
The other to drip for a set period of time, increasing the relay "time open" as the loop progresses (because gravity / water pressure?)
currently outputting text to terminal, will want this to display on a basic LCD.
Any suggestions / guidance is appreciated.
Here is my code so far:
void setup() {
const int ready_led = 6;
pinMode(ready_led, OUTPUT);
const int running_led = 7;
pinMode(running_led, OUTPUT);
Serial.begin(9600);
Serial.println("Press Start to Begin");
const byte startbutton = 10;
pinMode(startbutton, INPUT_PULLUP);
while (digitalRead(startbutton) == HIGH)
{
digitalWrite(ready_led, HIGH);
}
digitalWrite(ready_led, LOW);
Serial.println("Start Button Pressed, Begining PreSoak");
digitalWrite(running_led, HIGH);
PreSoak(); // Begin PreSoak Function
Serial.println("PreSoak finished, Starting Drip Cycle");
DripCycle(); // Begin Drip Function
Serial.println("Drip Cycle has ended");
digitalWrite(running_led, LOW);
}
void loop() {
FinishLED ();
}
// Define Functions
// PreSoak Function, 60 Drips a Minute, Drip for 6 Minutes (480 times) approx
void PreSoak()
{
const int pausebuttonPin = 9;
int pausebuttonState = 0;
pinMode(pausebuttonPin, INPUT);
const int relay_pin = 12;
pinMode(relay_pin, OUTPUT);
int presoakcount = 0;
while (presoakcount < 25)
{
pausebuttonState = digitalRead(pausebuttonPin);
if (pausebuttonState == LOW)
{
Serial.println("Presoak Paused");
}
else
{
digitalWrite(relay_pin, HIGH);
delay(250);
digitalWrite(relay_pin, LOW);
delay(500);
presoakcount++;
}
}
}
// Drip Cycle Function, approx 7 hours required to dispense 1L of water, test.
void DripCycle()
{
const int pausebuttonPin = 9;
int pausebuttonState = 0;
pinMode(pausebuttonPin, INPUT);
const int relay_pin = 12;
pinMode(relay_pin, OUTPUT);
int dripcyclecount = 0;
while (dripcyclecount < 5)
{
pausebuttonState = digitalRead(pausebuttonPin);
if (pausebuttonState == LOW)
{
Serial.println("Drip Stage 1 Paused");
}
else
{
digitalWrite(relay_pin, HIGH);
delay(500);
digitalWrite(relay_pin, LOW);
delay(2500);
dripcyclecount++;
}
}
while (dripcyclecount < 10)
{
pausebuttonState = digitalRead(pausebuttonPin);
if (pausebuttonState == LOW)
{
Serial.println("Drip Stage 2 Paused");
}
else
{
digitalWrite(relay_pin, HIGH);
delay(750);
digitalWrite(relay_pin, LOW);
delay(2250);
dripcyclecount++;
}
}
while (dripcyclecount < 15)
{
pausebuttonState = digitalRead(pausebuttonPin);
if (pausebuttonState == LOW)
{
Serial.println("Drip Stage 3 Paused");
}
else
{
digitalWrite(relay_pin, HIGH);
delay(1000);
digitalWrite(relay_pin, LOW);
delay(2000);
dripcyclecount++;
}
}
}
// Pulse LED when finished
void FinishLED ()
{
const int finish_led = 6;
float in, out;
for (in = 0; in < 6.283; in = in + 0.0005)
{
out = sin(in) * 127.5 + 127.5;
analogWrite(finish_led, out);
}
}