Hackster is hosting Impact Spotlights highlighting smart energy storage. Start streaming on Thursday!Stream Impact Spotlights on Thursday!
FelixAdiy
Published

Coffee Machine Water Auto-Refill Upgrade

Everybody hates it when they want the drink a cup of coffee and the water tank is empty. Here is the solution!

AdvancedProtip7,020
Coffee Machine Water Auto-Refill Upgrade

Things used in this project

Story

Read more

Schematics

The schematic

I needed this much volts , because the valve for the water needed more than the +12V which where printed onto the spec.
The sensor is like mentioned before the same as the coffee machine uses.

Code

the code

C/C++
int count = 0;     
int zeit = 350;// 600 = 1min //60= 6sek/ 10 = 1sek

   
bool pumpen = 0;




void setup() {


  pinMode(10 , OUTPUT); // Relais fr Pumpe
  digitalWrite(10,0);
 // pinMode(11,OUTPUT); // Nur zum Test als VCC fr einen Schalter
  attachInterrupt(digitalPinToInterrupt(2),TankEndlage,RISING);//Schalter fr Tank entnommen?
  attachInterrupt(digitalPinToInterrupt(3),Sensor,RISING); // Sensor von der Kaffeemaschine
}


void wait()
{
  delay(100);
  count++;
}

void loop() {


  if(digitalRead(3)==1 && digitalRead(2)==0)
  {
    delay(1000);
    if(digitalRead(3)==1)
    {
       pumpen=HIGH;
    }
   
  }

  while(count<zeit && pumpen==HIGH && digitalRead(2)==LOW)
  {
    digitalWrite(10,1);
    wait();
  }
 
  //Rcksetzen wenn while nicht mehr erfllt ist
  count = 0;
  pumpen= LOW;
  digitalWrite(10,0);
 

  
  
}

//Interruptroutinen der Sensoren/Schalter
void Sensor()
{
  delay(1000);
  if (digitalRead(3)==1)
  {
      pumpen= HIGH;
  }

}

 void TankEndlage ()
{
  pumpen=LOW;
 // digitalWrite(10,0);

} 

Credits

FelixAdiy

FelixAdiy

0 projects • 2 followers

Comments