Project Information

Shotbot Shot Bot Micaela

Synopsis
The Shot Bot pours a perfect shot from two liquor sources
Resources
Created by jessetutt | External Link
10 hours
1-5 pounds
12" x 12"
5-10 hours
Arduino
Powersource: Other - N/A

Locomotion: Stationary

Controller/CPU: Arduino

Description


My wife had her birthday. I had a hard time figuring out what to get her so I decided to build her an Arduino bot to make shots at her party.

This Arduino device detects motion, says one of three sounds and waits for a shot glass to be loaded. As as soon as a shot glass is loaded, it pours two half ounces from two different liquors. After it is done it plays a .mp3 file (which could be set to different sounds including the classic “LMFAO Feat. Lil Jon’s Shot song” which is what I used).

Super bright blue and red LEDs light up the Plexiglas frame.

It's a great project for a party and honestly it was a lot of fun making it. If you have any questions, feel free to reach out to me.

Here is a video:
YouTube Video

Here are the parts I used:

Quantity Cost Part Comment Link
1 29.95 Arduino Uno Board This is the device that makes it all tick! Buy it alone or as part of a kit (recommended for people new to it as they come with great manuals to help you learn how to use it) http://www.trossenrobotics.com/p/arduino-uno.aspx
10 in pack and used 9 $4.95 3-pin Sensor Cables Used to extend cables http://www.trossenrobotics.com/robotgeek-3pin-sensor-cable
1 21.50 Mp3 Arduino Sheild This device enables you to call a mp3 from an sd, usb, or from a memory chip on the card and play it http://www.elechouse.com/elechouse/index.php?main_page=product_info&products_id=2193
2 19.98 Solenoid Valve Used to close valve so liquor doesn’t spill all over http://www.trossenrobotics.com/solenoid_valve
2 24.95 DC Liquid Pump Used to pump liquor http://www.trossenrobotics.com/p/dc-liquid-pump-medium.aspx
1 10.95 Power Supply 12VDC 5.0A – US Used to power electronics (not the arduino) http://www.trossenrobotics.com/p/power-supply-12vdc-5a.aspx
1 11.95 RobotGeek Sensor Shield Used to clean up cabling but not required http://www.trossenrobotics.com/robotgeek-sensor-shield
1 10.00 Food Safe Clear Silicone Tubing 3.5mm I used 10 Meters or so by the time it was all done so buy lots! http://www.trossenrobotics.com/silicone_tubing
1 2.95 Barrel Jack Female Pigtail Lead 2.1 - 5.5mm Needed to connect power supply to the electronics http://www.trossenrobotics.com/store/p/6612-Barrel-Jack-Female-Pigtail-Lead-2-1-5-5mm.aspx
1 12.50 Motion Sensor (Any PIR will do) Used to detect motion http://www.trossenrobotics.com/store/p/6351-Electronic-Brick-PIR-Motion-Sensor-Digital.aspx
1 15.00 Ultra Sonic Range Measurement Module Used to determine how close (to the cm) a shot glass is from the device http://www.trossenrobotics.com/p/ultra-sonic-range-measurement-module.aspx
1 6.00 UBEC X3-6 which is a 12V to 6V converter The DC pump is 6V and the solenoid is 12V so this lets you power all 4 of the devices from a 12V Power Supply http://www.hobbyking.com/hobbyking/store/__17161__x3_ubec_6v_23v_input_5v_3a_output.html
10 in pack, used 9 2.95 3-Pin Coupler Used to connect the extension cables http://www.trossenrobotics.com/store/p/6681-3-Pin-Coupler-25-Pack.aspx
4 6.95 RobotGeek Relay Used to turn the solenoid and pumps on and off (one per device) http://www.trossenrobotics.com/robotgeek-relay

Here is a very rudimentary process for how to build it:

  1. First thing you need to do is the most difficult

Take the mp3 shield and desolder the top two dots on the TX Jumper and desolder the top two dots on the RX Jumper. Then solder the bottom two dots on the TX Jumper and solder the bottom two dots on the RX Jumper. This is a huge pain if you do not have a magnifying glass so if you do not or if you are new to soldering find someone else to do it!


  1. Create 4 .mp3 files. 3 for when people walk by and 1 for after the shot is poured. I used this site to enter some text and turn it into a mp3 file. http://www.fromtexttospeech.com/
  2. Copy four MP3 files one by one onto a thumb drive that is OLD. I used a 2GB drive. Newer ones will not work. Then make sure the mp3s when sorted alphabetically are song 1, 3, and 4 are the mp3s you want to play after someone walks by and song 2 which will be played after the shot is poured
  3. Plug the mp3 shield into the top of the arduino board. Make sure the power of the arduino is not connected. Plug the USB into the Mp3 shield USB slot. Press the copy button on the mp3 shield. Hold the copy button. Plug the power into the arduino and wait until the MP3 shield lights blink twice. As soon as they do, unplug the USB and power again as your songs have been loaded into the flash memory on the mp3 shield.
  4. Plug the Robotgeek sensor shield into the mp3 shield.
  5. Plug in the electronic into the RobotGeek Sensor Sheild Make sure to plug the black/red/white cables into the correct slot. Black is ground and white is the signal!
    1. REDLED into Analog 3
      1. Plug the black and white cables in from the cable. Red isn’t used.

    2. Green LED into Analog 4
      1. Plug the black and white cables in from the cable. Red isn’t used.

    3. Blue LED into Analog 5
      1. Plug the black and white cables in from the cable. Red isn’t used.

    4. Motion Sensor into Digital 3
      1. Plug the black, red, white cable in with black = ground

    5. Range Finder into Digital 5
      1. Plug the black, red, white cable in with black = ground

    6. Pump “A” Relay into Digital 12
    7. Solenoid “A” Relay into Digital 13
    8. Pump “B” Relay into Digital 10
    9. Solenoid “B” Relay into Digital 11

  6. Connect the Power supply pig-tail to the power supply.
  7. Connect Red cable from Pig Tail to:
    1. One of the two black cables from each of the solenoids
    2. red from the UBEC X3-6 (12V to 6V converter).

  8. Connect Black cable from Pig Tail to
    1. First cable connector on Solenoid “A” Relay
    2. First cable connector on Solenoid “B” Relay

  9. Run a red cable from:
    1. Second cable connector on Solenoid “A” Relay to Solenoid “A”
    2. Second cable connector on Solenoid “B” Relay to Solenoid “B”

  10. Connect the Red from the UBEC X3-6 which is a 12V to 6V converter into the red cable going to:
    1. Both DC Liquid Pumps

  11. Connect the exiting black cable from the UBEC X3-6 (6V output) into
    1. First cable connector on Pump “A” Relay
    2. First cable connector on Pump “B” Relay

  12. Run a red cable from:
    1. Second cable connector on Pump “A” Relay to Pump “A”
    2. Second cable connector on Pump “B” Relay to Pump “B”


Here is the code I developed:

/************************************************** *************************/
// Function: Measure the distance to obstacles in front and run pumpA and then pumpB if there is something in front of it
/************************************************** ***************************/
#include
#include
#include
//Analog
#define REDLED 16
#define GREENLED 17
#define BLUELED 18
//Digital
#define MOTION 3
#define ULTRA 5
#define PUMPA 12
#define SOLA 13
#define PUMPB 10
#define SOLB 11
int intSeconds = 0; //number of seconds after the please load shotglass sound has played before it plays again
int intProceed = 0; //variable used to store whether a glass is in front and the pumps should run
int intPleaseLoadShotGlass = 1; //Variable to store the song number since we loop through 3 different "Please load shotglass songs"
//MP3 Configuration
MP3 mp3;
//Motion Detector Configuration
int calibrationTime = 1; //the time we give the sensor to calibrate (10-60 secs according to the datasheet)
long unsigned int lowIn; //the time when the sensor outputs a low impulse
long unsigned int pause = 5000; //the amount of milliseconds the sensor has to be low before we assume all motion has stopped
boolean lockLow = true;
boolean takeLowTime;
//Ultrasonic Configuration
class Ultrasonic
{
public:
Ultrasonic(int pin);
void DistanceMeasure(void);
long microsecondsToCentimeters(void);
long microsecondsToInches(void);
private:
int _pin;//pin number of Arduino that is connected with SIG pin of Ultrasonic Ranger.
long duration;// the Pulse time received;
};
Ultrasonic::Ultrasonic(int pin)
{
_pin = ULTRA;
}
void Ultrasonic:istanceMeasure(void) /*Begin the detection and get the pulse back signal*/
{
pinMode(_pin, OUTPUT);
digitalWrite(_pin, LOW);
delayMicroseconds(2);
digitalWrite(_pin, HIGH);
delayMicroseconds(5);
digitalWrite(_pin,LOW);
pinMode(_pin,INPUT);
duration = pulseIn(_pin,HIGH);
}
/*The measured distance from the range 0 to 400 Centimeters*/
long Ultrasonic::microsecondsToCentimeters(void)
{
return duration/29/2;
}
/*The measured distance from the range 0 to 157 Inches*/
long Ultrasonic::microsecondsToInches(void)
{
return duration/74/2;
}
Ultrasonic ultrasonic(7);
void setup()
{
//Define if these devices will be input or outputs
pinMode(GREENLED, OUTPUT);
pinMode(REDLED, OUTPUT);
pinMode(BLUELED, OUTPUT);
pinMode(MOTION, INPUT);
pinMode(PUMPA, OUTPUT);
pinMode(SOLA, OUTPUT);
pinMode(PUMPB, OUTPUT);
pinMode(SOLB, OUTPUT);

//Turn on the white and blue LEDs that will light up the base and turn off the red one
digitalWrite(GREENLED, HIGH);
digitalWrite(BLUELED, HIGH);
digitalWrite(REDLED, LOW);

//Start the Serial port
Serial.begin(9600);

//Start the MP3 Player
mp3.begin(MP3_SOFTWARE_SERIAL); // select software serial
mp3.volume(0x1A); // set volum to the MAX
mp3.set_mode(MP3::SINGLE); //Set it to only play the song once

Serial.println("Warm up the sensors");
for(int i = 0; i < calibrationTime; i++) //give the sensor some time to calibrate
{
delay(1000);
Serial.println(".");
}
Serial.println("Sensors warmed up");
}
void loop()
{
//Set variables
long RangeInInches;
long RangeInCentimeters;
//Check to see if the Motion Detector detects motion. If so then proceed
if(digitalRead(MOTION) == HIGH)
{
Serial.println("Motion Detected");

//Figure out what intPleaseLoadShotGlass is and play the appropriate song
switch (intPleaseLoadShotGlass) {
case 1:
//Play song.
mp3.play_spi_flash(0x0001);
Serial.println("Play song 1"); //Care for another?
intPleaseLoadShotGlass=2;
Serial.println("Change intPleaseLoadShotGlass=2");
break;
case 2:
//Play song.
mp3.play_spi_flash(0x0004);
Serial.println("Play song 2"); //You sure are thirsty
intPleaseLoadShotGlass=3;
Serial.println("Change intPleaseLoadShotGlass=3");
break;
case 3:
//Play song.
mp3.play_spi_flash(0x0003);
Serial.println("Play song 3"); //Are you sure you need another?
intPleaseLoadShotGlass=1;
Serial.println("Change intPleaseLoadShotGlass=1");
break;
}

delay(2000);
intSeconds = 0;
intProceed = 0;
do
{
//Check to see if there is a shot in from of the Ultrasonic
ultrasonic.DistanceMeasure();
RangeInCentimeters = ultrasonic.microsecondsToCentimeters();
Serial.print(RangeInCentimeters);
Serial.println(" cm");
if (RangeInCentimeters < 4)
{
Serial.println("Shot Glass Detected the first time. Lets try detecting it again to make sure this isn't a false positive");
intProceed = 1;
}
if (intSeconds > 10)
{
Serial.println("No shot glass detected so exit and keep trying");
intProceed = 1;
}
intSeconds++;
Serial.print(intSeconds);
Serial.println(" seconds out of twelve");
delay(1000);
} while (intProceed < 1);
Serial.println("Exit");

//Check a second time to make sure this was't a glitch if there is something within 4 CM of the Ultrasonic
if (RangeInCentimeters < 4)
{
delay(1000);

//Check to see if there is a shot in from of the Ultrasonic
ultrasonic.DistanceMeasure();
RangeInCentimeters = ultrasonic.microsecondsToCentimeters();
Serial.println(RangeInCentimeters);//0~400cm
Serial.println(" cm");

if (RangeInCentimeters < 4)
{
//Turn off green and blue LEDs that light up the base with the red
digitalWrite(GREENLED, LOW);
digitalWrite(BLUELED, LOW);
//Turn on Red LED
digitalWrite(REDLED, HIGH);
//turn Pump A and SOL A on
digitalWrite(PUMPA,HIGH);
digitalWrite(SOLA, HIGH);
Serial.println("Pump A and Soleniod A ON");
delay(1100);
digitalWrite(PUMPA,LOW);
digitalWrite(SOLA, LOW);
//turn Pump B and SOL B on
digitalWrite(PUMPB,HIGH);
digitalWrite(SOLB, HIGH);
Serial.println("Pump B and Soleniod B ON");
delay(1100);
digitalWrite(PUMPB,LOW);
digitalWrite(SOLB, LOW);
//Play second song on flash
mp3.play_spi_flash(0x0002);
delay(7000);

//Keep watching the Ultrasonic until the shot glass has been removed
do
{
//Check to see if there is a shot in from of the Ultrasonic
ultrasonic.DistanceMeasure();
RangeInCentimeters = ultrasonic.microsecondsToCentimeters();
Serial.print(RangeInCentimeters);//0~400cm
Serial.println(" cm");
} while (RangeInCentimeters < 4);
}
//Turn on green and blue LEDs to light up the base and turn red off
digitalWrite(GREENLED, HIGH);
digitalWrite(BLUELED, HIGH);
//Turn on Red LED
digitalWrite(REDLED, LOW);
}
}
}