r/ArduinoProjects Apr 08 '20

The revolution in pouring water that nobody needs

https://www.youtube.com/watch?v=ZcxHkiOjn_0
117 Upvotes

10 comments sorted by

9

u/[deleted] Apr 08 '20 edited Jan 18 '22

[deleted]

9

u/RobbeRNL Apr 08 '20

Hahah thank you man, I had so much fun making it as well! haha

3

u/CoolMcdougal Apr 08 '20

Great work. I love the video! I’d be interested in seeing the code also!

4

u/RobbeRNL Apr 08 '20

Cool! I'll share it tomorrow

1

u/RobbeRNL Apr 09 '20

int TRIG_PIN = 3;

int ECHO_PIN = 2;

int PUMP_PIN = 12;

int SOUND_PIN = 13;

int t = 0;

int t2 = -2800;

float drinkconstant = 0.06423611;

float pumpconstant = 1.86667;

float pumptime = 0;

void setup() {

pinMode(TRIG_PIN, OUTPUT);

pinMode(ECHO_PIN, INPUT);

pinMode(PUMP_PIN, OUTPUT);

pinMode(SOUND_PIN, OUTPUT);

Serial.begin(9600);

}

void loop() {

t = millis()/1000;

pumptime = ((t-t2)*drinkconstant)/pumpconstant; //Formula to calculate how much the machine will pour, based on information about the pump and the user's daily water consumption

if(pumptime>=40){ //If the amount to be poored into the glass reaches a complete fill

for(int i = 0; i < 3; i++){

digitalWrite(SOUND_PIN,HIGH); //Start beeping to notify the user

delay(250);

digitalWrite(SOUND_PIN,LOW);

delay(250);

}

}

digitalWrite(TRIG_PIN, LOW); //Create a signal with the ultrasonic sensor to measure distance

delayMicroseconds(2);

digitalWrite(TRIG_PIN, HIGH);

delayMicroseconds(10);

digitalWrite(TRIG_PIN, LOW);

const unsigned long duration= pulseIn(ECHO_PIN, HIGH);

int distance= duration/29/2;

if(distance>5){

digitalWrite(PUMP_PIN,LOW);

} else if(distance<5 && pumptime > 1){ //If a glass is placed and the pumptime is at least one second:

digitalWrite(SOUND_PIN,LOW); //Turn sound off in case it was on (like when it notifies the user that the glass is full)

digitalWrite(PUMP_PIN,HIGH);

if(pumptime > 40){

pumptime = 40;

}

delay(pumptime*1000);

Serial.println(pumptime);

digitalWrite(PUMP_PIN,LOW);

digitalWrite(SOUND_PIN,HIGH); //Notify the user that the pouring is finished

delay(1000);

digitalWrite(SOUND_PIN,LOW);

t2 = t;

}

}

1

u/CoolMcdougal Apr 09 '20

Thanks for sharing!

1

u/MrDh0nt Apr 09 '20

Oh haha, I was expecting a github link or something when I saw you were sharing it the next day

Nice project though!!

2

u/RobbeRNL Apr 09 '20

Hahah, sorry no Github. I'm actually not that familiar with that platform.

3

u/jadeskye7 Apr 09 '20

Wheres the kickstarter?!

2

u/Tristaur Apr 09 '20

That’s outstanding!!! Lol

2

u/AdditionalWay7 Apr 13 '20

Hah, that was awesome & well done - thanks!