Concept
I forget to drink water really often and always end up thirsty and dehydrated. So I thought of making a switch related to drinking water. This would make hydrating fun and mightg help people like me drink more water.
Here is my code
My ciurcuit:
Demonstration video
Code snippetvoid
void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT);
pinMode(A2, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int buttonState = digitalRead(A2);
if (buttonState == HIGH) {
//Not repeating the code uses the void loop and makes the LED blink as long as the circuit is connected.
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
delay(200);
} else {
digitalWrite(13, LOW);
}
}
I used pin 13 as output to the LED and pin A2 as input from the switch circuit. The circut structure was the same as our practice input structure in class, except changing the switch to the cup. The 5v end was connected to one aluminum foil on the cup. the other piece of foil was inputted into pin A2 and connected to a 10k$\Omega$ pull down resistor. The LED was connected using normal circuit from pin 13.
The switch is connected when there is water conducting the electricity between the two aluminum foils, which is what happens when I drink water. This results in buttonState==HIGH and the LED running the code to blink. When the water is removed the circuit is disconnected, resulting in buttonState == LOW
Reflection
The first time I buit the circuit I put the foils too close to each other so water drops would stick between them even if I am not drinking, causing the circuit to be connected all the time. I solved this by moving the foil apart and also adding tape layer on top of the foils on bottom corner of the inside of the cup of where I would sip. This secured the foil in place and also served as a insulation for any small amounts of residue water whithout affecting the actual initiation of the circuit.

