Aedan McHughAlex Sumida
Published © GPL3+

Bionic Bartender

The perfect cocktail at the push of a button!

BeginnerShowcase (no instructions)4 hours2,566
Bionic Bartender

Things used in this project

Story

Read more

Schematics

Bionic Bartender Circuitry

This circuit schematic shows the basic wiring layout for our Bionic Bartender. The first photon has a push button and an LED light. When the button is pushed the LED illuminates and the event is published. The second photon then subscribes to this event and sends power to the relays from D0 and D7 allowing the pumps to run and your beverage to be created.

Code

Publish Code

C/C++
This code will publish an event when the button is pushed. This event will cause the other photon to begin pouring your beverage.
int ledPin = D1;
int buttonPin = D0;
void setup()
{
  pinMode( buttonPin , INPUT_PULLUP); 
  pinMode( ledPin , OUTPUT ); 
}
void loop()
{
  if( buttonState == LOW )
  {
    digitalWrite( ledPin, HIGH);
  }else{
  
    digitalWrite( ledPin, LOW);
  }
   delay(1000);
    if (digitalRead(buttonState) == HIGH){
        Particle.publish("ButtonPush","The button is pushed",PRIVATE);
    }

}

Subscribe Code

C/C++
This code controls both the pumps that will create your beverage.
int led = D7;
int pump = D5;

void setup() {

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

    Particle.subscribe("ButtonPush", pumpOn, "3e0030000f51353338363333");

}

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

digitalWrite(led, LOW);

  delay(3227);
  
digitalWrite(pump, LOW);

    delay(1613);
    
digitalWrite(led, HIGH);
    
digitalWrite(pump, HIGH);

}

Credits

Aedan McHugh

Aedan McHugh

1 project • 0 followers
Alex Sumida

Alex Sumida

1 project • 0 followers

Comments