Nathan Aranda
Published

Automatic water dispenser

A project that automatically dispenses 8 ounces of water into your glass.

BeginnerWork in progress35
Automatic water dispenser

Things used in this project

Hardware components

Photon 2
Particle Photon 2
×1
Linear Solenoid, 12 VDC
Linear Solenoid, 12 VDC
Solenoid varies for this project. Measure the amount of newtons needed to pull or push your target to dispense the water, then get a solenoid that exceeds that newton count by 1 or 2 more. For example a 12v 10N 10mm solenoid is what I used.
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
×1
Resistor 1k ohm
Resistor 1k ohm
×1
PTS 645 Series Switch
C&K Switches PTS 645 Series Switch
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Hand tools and fabrication machines

10 Pc. Jumper Wire Kit, 5 cm Long
10 Pc. Jumper Wire Kit, 5 cm Long
Needs at least 9.

Story

Read more

Schematics

Circut

All are wires in the drawing, but the light green line. That is the diode in the materials. Also due to spacial issues, the transistor has three pins. One pin should be above the gray wire, the middle pin hasn't any wire and the other pin is above the light green wire.

Code

Code to activate Solenoid using a button for a set amount of time.

C/C++
This code ultimately activates my solenoid when the button is pressed for exactly 4.4 seconds(the time my filter takes to fill 8 ounces glass of water)
const int buttonPin = 2; // Pin connected to the button
const int solenoidPin = 4; // Pin connected to the solenoid control

bool buttonPressed = false; // Variable to track button press

void setup() {
  pinMode(buttonPin, INPUT_PULLUP); // Set button pin as input with internal pull-up
  pinMode(solenoidPin, OUTPUT); // Set solenoid pin as output
  digitalWrite(solenoidPin, LOW); // Start with solenoid off
}

void loop() {
  // Check if the button is pressed
  if (digitalRead(buttonPin) == LOW && !buttonPressed) {
    // Button is pressed, activate solenoid for 4.4 seconds
    buttonPressed = true;
    digitalWrite(solenoidPin, HIGH); // Turn on solenoid
    delay(4400); // Keep solenoid on for 4.4 seconds
    digitalWrite(solenoidPin, LOW); // Turn off solenoid
  }
  
  // Reset the button state when released
  if (digitalRead(buttonPin) == HIGH) {
    buttonPressed = false; // Allow for another press
  }
}

Credits

Nathan Aranda
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.