Andrew DenbowEvan Thurman
Published

Automatic Shot Dispenser

Do you ever get tired of pouring drinks by hand? This project uses 2 particle photons to automatically dispense the perfect shot.

BeginnerFull instructions provided4 hours3,128
Automatic Shot Dispenser

Things used in this project

Hardware components

12v battery charger
×1
Photon
Particle Photon
×2
Relay (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×2
Breadboard (generic)
Breadboard (generic)
×2
DC 12V micropump
×1
12V battery charger (generic)
×1
food grade hose
×1

Software apps and online services

Mobicle
ControlEverything.com Mobicle
Google Sheets
Google Sheets
Maker service
IFTTT Maker service

Story

Read more

Schematics

Drink Dispenser

Code

Publish Code

C/C++
This code publishes the event to the cloud.
 //      +----------| USB |----------+
// *                          |          +-----+       *  |
 //*                          | [ ] VIN           3V3 [ ] |
 //*                          | [ ] GND           RST [ ] |
 //*                          | [ ] TX           VBAT [ ] |
 //*                          | [ ] RX  [S]   [R] GND [ ] |
 //*                          | [ ] WKP            D7 [*] |<-LED triggers jumpered to pin D0 (digital write)
 //*                          | [ ] DAC +-------+  D6 [ ] |
 //*                          | [ ] A5  |   *   |  D5 [ ] |
 //*                          | [ ] A4  |Photon |  D4 [ ] |
 //*                          | [ ] A3  |       |  D3 [ ] |
 //*                          | [ ] A2  +-------+  D2 [ ] |
 //*                          | [ ] A1             D1 [ ] |
 //*                          | [ ] A0             D0 [*] |<-This pin reads the signal from the D7 pin (digital read)
 //*                          |                           |
 //*                           \    []         [______]  /
 //*                            \_______________________/
 //*
//The D7 pin is jumpered to the D0 pin.  





int led = D7;
int lightsensor = D0;
int val = 1;

void setup() 
{
pinMode(led, OUTPUT);
pinMode(lightsensor, INPUT_PULLDOWN);


digitalWrite(led, HIGH);
digitalWrite(led, LOW);

Particle.function("togglelights", togglelights);

}

int togglelights(String command){
    if(command == "On" || command == "on" || command == "ON"){
        digitalWrite(led,LOW);
        return 1;
    }
 else if (command=="off") {
        digitalWrite(led,HIGH);
    
        return 0;
}
else {
    return -1;
}
}

void loop() {
    
    val = digitalRead(lightsensor);
    digitalWrite(led, val);

 
    if(digitalRead(lightsensor) == 1){
        Particle.publish("drink_maker44","flowin",60);
    }
   else 
   {delay(3000);
   }
}

Subscribe Code

C/C++
This is the code for the photon that subscribes to the event.
//      +----------| USB |----------+
 //*                                          |          +-----+       *  |
 //*  This connects to the vcc on the relay ->| [*] VIN           3V3 [ ] |
 //*                connects to GND on relay->| [*] GND           RST [ ] |
 //*                                          | [ ] TX           VBAT [ ] |
 //*                                          | [ ] RX  [S]   [R] GND [ ] |
 //*                                          | [ ] WKP            D7 [*] |<-connects to the IN1 on the relay
 //*                                          | [ ] DAC +-------+  D6 [ ] |
 //*                                          | [ ] A5  |   *   |  D5 [ ] |
 //*                                          | [ ] A4  |Photon |  D4 [ ] |
 //*                                          | [ ] A3  |       |  D3 [ ] |
 //*                                          | [ ] A2  +-------+  D2 [ ] |
 //*                                          | [ ] A1             D1 [ ] |
 //*                                          | [ ] A0             D0 [ ] |
 //*                                          |                           |
 //*                                           \    []         [______]  /
 //*                                            \_______________________/
 //*

int led = D7;


void setup() {

    pinMode(led, OUTPUT);
    digitalWrite(led, HIGH);

    Particle.subscribe("drink_maker44", pumpOn, "420029001147353138383138");

}



void pumpOn(const char *event, const char *data)
{

digitalWrite(led, LOW);

  // We'll leave it on for 1.7 second...
  delay(1700);


  // Then we'll turn it off...
  digitalWrite(led, HIGH);
  
  delay (-1700);
  // the negative cuts off the loop


}

Credits

Andrew Denbow

Andrew Denbow

1 project • 0 followers
Evan Thurman

Evan Thurman

1 project • 0 followers

Comments