Introduction: Party Safe This Summer With a Arduino Blood-Alcohol Reactive LED Cup

About: I am a student in Charlotte, North Carolina who is interested in electronics and programming. I learn best hands-on and by making things, so I will put my projects on Instructables to help myself learn and oth…

Project Level Difficulty: Intermediate

Skills Needed:

- Reading and replicating a diagram

- Soldering if you opt not to purchase pre-soldered parts

Project Introduction

In the United States and across the world, alcohol has posed severe health threats when consumed in an irresponsible way. Deaths due to driving under the influence and liver damage, as well as long-term effects such as the possible brain and kidney damage, may result from the irresponsible consumption of alcohol. In the United States alone, 250 billion dollars was lost due to alcohol misuse (NIAAA, 2010), as well as over 88,000 people, making alcohol the third leading preventable cause of death in the country. The question for this project is as makers, how can we address this problem and make sure fun celebrations with alcohol like parties can stay safe and fun?

My answer to this question was to find a way to estimate and then visualize the predicted BAC of the user to allow them to better understand what state they were in. For this project, I used the Arduino microcontroller with a water-level sensor, LED ring, and an LCD screen to track how many drinks a person has consumed, and then to find a way to estimate the blood-alcohol content (BAC) of the user based on sex and weight. The estimated BAC, depending on what range it was in, determines the animation of the LED ring below. The ranges fall in between four distinct areas: Safe, impaired, intoxicated, and deadly. My hope is that by creating this project, you will not only have created a usable Arduino project but also have gained a better understanding of how we metabolize alcohol and possibly even some basic programming if you choose to look over the commented code.

How does the cup know how many drinks I have had?

If the water level sensor's analog value surpasses 300, a boolean value representing the cup will be recorded as HIGH (full). If the analog value of the sensor is below 300, the boolean value representing the cup will be recorded as LOW (empty). To record a drink being added to the cup, this boolean value must change from empty to full.

How did you determine BAC?

In order to make this project as accurate as possible, I used data from Saint Benedict & Saint John's University on how much the BAC of an individual increased per drink consumed. This program not only considers weight but also the sex of the user in the calculation of the BAC of the user. This is because BAC is based on how fast a body is able to metabolize alcohol, which is different between men and women and people of different weights. The charts can be seen here.

Why are the BAC ranges differently for different people?

The BAC ranges are based directly on the data obtained from SBSJ University, which considers how much alcohol a user must have in their system for them to be in one of four ranges:

- Safe: The only safe range to operate a vehicle in (represented by rainbow animation)

- Impaired: Criminal charges may result if you operate a vehicle in this range (represented by orange animation)

- Intoxicated: Criminal charges will result if you operate a vehicle in this range (represented by red lights)

- Deadly: If you have not already passed out, you are in immediate medical danger in this range (represented by flashing red and white lights)

But I can take alcohol well, so is this cup inaccurate?

How well you are able to act after consuming alcohol will not matter much if you blow past the legal limit while driving. The data used in this project considers what the legal and medical ranges of a user's BAC are, while also considering the weight and gender of the user.

Supplies

General electronics supplies for this project include:

- Two pushbuttons

- Jumper wires

- 10k potentiometer

- 2 10k resistors

- 1 220 resistor

Special parts/modules:

- An Arduino (I used an Uno for this project, but many cheaper alternatives exist)

- A water-level sensor (NOTE: These sensors are often inaccurate and corrode quickly, which was a major frustration of developing this project. However, I was able to find a solution so that my difficulties with this project did not translate into your difficulties with this project.)

- A LED Ring (12 LEDs)

- An LCD Screen

Tools:

- Soldering iron (Only needed if buying LED ring without headers)

- 3d printer (Optional)

Step 1: Download Arduino IDE and Copy Required Code

No computer programming is required for this project, all you have to do is copy the code from the here and paste it into the Arduino IDE. To download the Arduino IDE:

Downloading and configuring Arduino IDE:

- Visit the Arduino website and choose the download for your system

- Once the download is complete, get the COM port number for the Arduino. Plug the Arduino in and navigate to your Device Manager. Under ports, look for your Arduino and take note of the port number. It should look something like this: COMx (Where x is a number 1-9)

- Using the COM port number, configure the IDE for your board and port by opening the Arduino IDE and selecting "Tools" on the top bar. Select "Board" and choose your model. Next, choose "Port" and select the port you saw for your Arduino in Device Manager.

Obtaining Project Code

- Copy code from this step and paste it into the white section of the Arduino IDE. Make sure to first delete everything on the sketch, such as the loop() and void() routines, as these are implemented in the code you are copying and pasting.

Step 2: Download Required Libraries From Arduino IDE

The libraries used in this project include "Wire", "LiquidCrystal", and "Adafruit Neopixel". The sketch needs these libraries to communicate with the components used in this project. To download these libraries:

- Select "Sketch" on the top bar

- Select "Include library" from the drop-down menu

- Select "Manage libraries"

- Search for the three libraries (Wire, liquid crystal, and Adafruit Neopixel) used in this project and download each one.

Please note that failure to download these libraries will result in an error while the sketch is being compiled. After this step, attach the cable from your Arduino to your laptop and press the arrow button in the top-left corner of the IDE. This will compile and upload the sketch to the Arduino. Now that we are done with all the programming-related steps, let's move onto wiring!

Step 3: (Optional) Solder Headers Onto Parts

If you opted to purchase parts for this project that did not already have header pins soldered onto them, you will need to do this yourself. Don't worry too much about this part, the soldering for this project is very straightforward.

- Create a ventilated environment to solder in, preferably with a fan containing a filter. If you do not have such a fan, you can do what I do and open the windows and turn on the fan or go to the garage while it is open.

- Heat up your soldering iron and make sure that you also have a wet sponge to wipe excess solder off on.

- Set up the headers and the part you want to attach the headers in using a helping hand or another tool that allows you to arrange the parts while allowing you to hold the soldering iron.

- Touch the solder to the soldering iron while on the connection between the header pin and the part you are soldering the pins to. Take the iron off when enough solder has formed to ensure electrical contact between the header pins and the part. Wipe any excess solder off on the sponge and repeat this process for all pins.

- After all pins are soldered, place the soldering iron in the stand, turn the knob to "off", and unplug the iron. Wait until the iron has completely cooled to put it away.

Step 4: Follow Picture and Wire Arduino to Components

In this step, you will need to user jumper wires to connect the parts necessary for the project to the Arduino. I have provided a Fritzing file to do this, which can be seen on this step. Please see below for a list of common questions that I ask myself if I run across a problem with wiring:

- Are my ground and power rails properly connected to each other and the 5v and GND pins of the Arduino?

- Did I mess around with my potentiometer if the LCD display is not showing? (Try turning the potentiometer around to change the resistance if the white characters are not appearing properly)

- Are the GND and VCC connected to each part properly to the correct pin? Is the 5-volt setting being used? (All sensors and components in this project will use 5 volts, not 3.3 volts.

- Was a wire accidentally placed one connection away from where it was supposed to be?

NOTE: When working with electronics, always make sure that the circuit is not powered while it is being changed. Otherwise, parts may be damaged and when working with greater voltages, bodily harm could result.

Step 5: Assemble Project "Coaster"

You may notice that the headers of the LED ring stick out and do not allow you to actually place the cup flat against a surface. To address this problem, we will attach the LED ring to a 3d printed part that will allow for the ring to be placed flat on a table. The 3d file can be found on this step. If you do not have a 3d printer, do not worry, this print cost a 1.40 to make at my local library. If your local library does not have a 3d printer, other options include Staples and online sellers. It should also be noted that the certain part I have attached is not the only compatible one, it is just the way to make a model for me. So if you are good with woodworking or other crafts, those would be more than acceptable!

If you choose to print the part for this project:

- Download the STL file to import to a slicer such as Cura

- Measure the diameter of a bottom of a cup of your choice

- Adjust the scale of the model (in millimeters if using Cura) to your measurement

Step 6: Attach Coaster and Sensor to Cup of Your Choice

Next, take your coaster and use adhesive to attach it to the bottom of the cup you measured. Now, the jumper wires will be able to access the water-level sensor and the LED ring, and also lay flat on the table. Now you have to attach the sensor. It is very careful to be considerate about the placement of the sensor, as these sensors, while marketed as analog, really only put out two signals- water or no water. This caused very many problems for me, but I was able to find a way to solve it so that others did not experience the same frustrations with this project. The key is to place the sensor near the top of where the liquid will be when the cup is full. This will make sure that the sensor is able to register an "empty" state and therefore able to count the next poured beverage.

Step 7: Beautify Project and Protect Wires

At this point, you are probably left with a clump of wires and parts that looks like the photo attached. What you do to make the project look better is completely up to you, as long as you keep these criteria in mind:

- You must be able to plug a charger into power the Arduino

- You must cut out holes or design spaces for the user to access the LCD screen, buttons, the water-level sensor, and the LED ring.

- You must protect the electronic components from getting wet, as this is a possibility since the project focuses on drinks.

Some choices for enclosing the project are:

- A shoebox or carton

- A waterproof electronics project enclosure such as the one found here

- A 3d printed design (This is the option I wanted to pursue, however, it was too expensive to print a design like this at my library)

Step 8: Drink Responsibly!

After attaching your cup to the coaster and the water sensor, you are good to go! You will know that everything is working properly when the LCD screen prompts you for your gender and weight. One button corresponds to weight, while the other corresponds to sex. You can click each one to see which one it is before labeling it. After selecting your correct weight (values are in steps of 20) and sex, click both buttons simultaneously. This will start the rest of the program, and you will see the LED ring flash a rainbow pattern. The cup is now ready for you to pour a drink. As you consume and pour more drinks, the program will use the BAC table discussed in the introduction to determine a BAC. Please note that this program assumes one standard drink for each cup, please see the picture (University of South Alabama), or visit here to see how your favorite drink translates. Also note that the goal of this project is not to encourage any illegal activity, but to promote safe drinking for those old enough to consume alcohol. Also, while I am very happy with how accurate the BAC estimation is assuming a standard drink, this project is a tool to help you drink safe, but holds no liability if you choose to drive after the consumption of any alcohol.

Step 9: (Optional) Troubleshooting

- "Problem uploading to board" error: When trying to compile and upload the sketch to the Arduino, this error will result if your COM port is not correctly configured (See step one on how to find and set the correct COM port) or your board is not plugged in.

- LCD screen not showing white characters: If the blue light of your LCD is on but you see no white characters after uploading the sketch, this is most likely due to contrast problems. To fix this, just turn your potentiometer to the right (Turn to the left if you see white blocks with your characters).

- The project is not counting drinks correctly: This error is a water-level sensor problem. Water-level sensor modules corrode quickly and are known for being very inaccurate. However, that should not concern you for this project, as I treated the sensor as a digital sensor rather than an analog one. See step six on how to correctly attach you water-level sensor.

- A module is extremely hot and not sending the correct values: This is the result of either a GND or VCC connection being broken, probably while working with other wires. Make sure that the GND and VCC connections to the sensor are complete and follow them to the GND and 5v pins from the component, to the breadboard, to the Arduino to look for errors.

- I accidentally went over my weight: Do not worry, the weight setting returns to 100 after 240, so you can just keep rotating through the options to get back to your weight.

If issues persist, connect the cable from the Arduino to the laptop, open the IDE, and run the sketch. While the sketch is running, several values will be displayed in the serial monitor, allowing you to see what is not functioning as it is supposed to. To access the serial monitor, run the program and "Tools" and then "Serial Monitor" from the drop-down menu.

Step 10: Reflection

On the programming side, I am very happy with the way this project turned out. It took a while for me to write since I am still a beginner, but I was able to learn many new libraries and achieve to goal of predicting BAC, and I feel that I took no shortcuts in estimating the BAC as I used both sex and weight (This made up a majority of the sketch). However, I need to approve the design. While I do not own a 3d printer or know woodworking, I really wanted my project to be presented in a better manner. I intend to soon get an Ender 3, and the first thing I will do is come right back to this same instructable to improve the design. As my first instructable ever, I feel the process went well and I am very happy with the extent to which this project addressed the prompt I created for the Party Challenge, but design something I would like to later return to when I have the resources.

Party Challenge

Participated in the
Party Challenge