Introduction: Automatic Shots Dispenser

I made an automatic shots dispenser for parties. You place down 1 to 4 shot glasses and select how many glasses you want filled by turning a potentiometer. Then you press a button and the selected amount of glasses will be filled up by a liquid of your choosing.

I do not have many iterations, as the design didn't change much. Mostly the size of the 3D printed parts changed so that it would fit in the timeframe and size of the 3D printers I had acces to.

With this project I learned how relays work and how you can fit several 3D printed parts together to make up for a smaller 3D printer.


The difference in the models of the screenshot are not big enough for me to outline them.

Supplies

Step 1: Schematics

Schematics

Step 2: Code

#include "SevSeg.h"
SevSeg sevseg;
#include <Stepper.h>

#define POTENTIOMETER_PIN A0
#define BUTTON_PIN A5

int glassAmount = 4;

const int steps_per_rev = 700;  

int steps_per_rev_array[] {
170,
170,
155,
160
};

#define IN1 10
#define IN2 11
#define IN3 12
#define IN4 13
Stepper motor(steps_per_rev, IN1, IN3, IN2, IN4);

#define RELAY1 9
#define RELAY2 8


bool canTurn = false;


void setup(){
    Serial.begin(9600);
    motor.setSpeed(10);

//Setup button
    pinMode(BUTTON_PIN, INPUT_PULLUP);


    //setting the pins for the relay
    pinMode(RELAY1, OUTPUT);
    pinMode(RELAY2, OUTPUT);

    digitalWrite(RELAY2, HIGH);    
      //Setup for seven segment display
      byte numDigits = 1;
      byte digitPins[] = {};
      //Defines Arduino pin connections in order: A, B, C, D, E, F, G, DP
      byte segmentPins[] = {4,3, 0, 1, 2, 5, 6, 0};
      byte displayType = COMMON_CATHODE;
      bool resistorsOnSegments = true;
      sevseg.begin(displayType, numDigits, digitPins, segmentPins, resistorsOnSegments);
      sevseg.setBrightness(90);

}

void loop(){
//Reads the value of the Potentiometer to define how many glasses are to be filled
//And to display the value on the seven segment Display
    if(analogRead(POTENTIOMETER_PIN) > 0 && analogRead(POTENTIOMETER_PIN) < 205)
    {
          sevseg.setNumber(0);
          sevseg.refreshDisplay();
          glassAmount = 0;
    }
    else if(analogRead(POTENTIOMETER_PIN) > 205 && analogRead(POTENTIOMETER_PIN) < 410)
    {
          sevseg.setNumber(1);
          sevseg.refreshDisplay();
          glassAmount = 1;
    }
    else if(analogRead(POTENTIOMETER_PIN) > 410 && analogRead(POTENTIOMETER_PIN) < 615)
    {
          sevseg.setNumber(2);
          sevseg.refreshDisplay();
          glassAmount = 2;
    }
    else if(analogRead(POTENTIOMETER_PIN) > 615 && analogRead(POTENTIOMETER_PIN) < 820)
    {
          sevseg.setNumber(3);
          sevseg.refreshDisplay();
          glassAmount = 3;
    }
    else if(analogRead(POTENTIOMETER_PIN) > 820 && analogRead(POTENTIOMETER_PIN) < 1025)
    {
          sevseg.setNumber(4);
          sevseg.refreshDisplay();
          glassAmount = 4;
    }

//When the button is pressed the motor and pump will start working
    if(digitalRead(BUTTON_PIN) == 0)
    {
       canTurn = true;            
    }

    if (canTurn)
    {
//Fills glass for 2 seconds
      digitalWrite(RELAY2, LOW);  // turn on relay 2
      delay(2000);                // wait 2 seconds
      digitalWrite(RELAY2, HIGH);    
//Turns the stepper motor the right amount of degress for the next glass
      for (int i = 0; i < (glassAmount - 1); i++)
      {  
        motor.step(steps_per_rev_array[i]);
        delay(1000);
//Fills the next glass before turning the stepper motor further
        digitalWrite(RELAY2, LOW);  // turn on relay 1
        delay(2000);                // wait 2 seconds
        digitalWrite(RELAY2, HIGH);    
      }

//Sets the stepper motor back to it's starting position for the next time
      for (int i = 0; i < (glassAmount - 1); i++)
      {  
        motor.step(-steps_per_rev_array[i]);
      }
//To not repeat the sequence until the button is pressed again
      canTurn = false;
    }
}

Step 3: The Separate Construction Steps From Start to Finish

I have no images, or documentation on what steps I did during what parts of the process.

Step 4: Video of Your Working Project