Jump to main content

Make an Automatic Pill Dispenser

1
2
3
4
5
14 reviews

Abstract

Remembering to take medicine at the right time can be hard, especially if you need to take multiple medications at different times of day. It might not be a big deal if you forget to take your daily multivitamin, but for some people, forgetting to take medication at the right time can be dangerous. What if you had a device that could not only set off an alarm at the right time, but also automatically dispense the right pills for you? In this project, you will build an automatic medicine dispenser to do just that!

Summary

Areas of Science
Difficulty
 
Time Required
Short (2-5 days)
Prerequisites

Previous experience with Arduino is required to do this project. See our How to Use an Arduino tutorial page if you are new to Arduino.

Material Availability

A kit is available from our partner Home Science Tools. See the Materials section for details.

Cost
Average ($50 - $100)
Safety

The dispenser in this project is not child-proof. Do not use with real medication in households with small children. For demonstration purposes you can use candy instead. 

Credits
Ben Finio, PhD, Science Buddies

Note: If you have never used an Arduino before, please do at least the first six tutorials on our How to Use an Arduino page before attempting this project.

Objective

Build and customize an automatic pill dispenser. 

Introduction

Have you ever had to take medication at the same time each day? Maybe you take a multivitamin or an allergy pill at breakfast, or maybe you have been sick and had to take antibiotics in the morning and at night. Especially if you have to take your medication more than once a day, or even different medications at different times of day, this can be difficult to remember! You can buy a pill organizer like the one in Figure 1 to help you keep track, but you still need to remember to take the medication or set a separate alarm. 

A plastic pill dispenser with one compartment for each day of the week.
Figure 1. A plastic pill organizer. 

An automatic pill dispenser combines the features of a pill organizer and an alarm into one device. You pre-load the device with your medication(s), set the times, and then it will automatically dispense the right amount of medication at the right time(s) each day. This project will show you how to build an automatic pill dispenser like the one in Figure 2 using an Arduino. The dispenser uses a servo motor to turn a paddle wheel that holds pills in different compartments. The servo is programmed to rotate at certain times. A real-time clock (RTC) keeps track of the time. When a compartment slides over the hole, the pills fall down a chute into the tray at the front of the device.

Automatic pill dispenser with screen that says take medicine!
Figure 2. An Arduino-based automatic pill dispenser. 

Using an Arduino allows you to customize your pill dispenser and add other features. For example, you can add a liquid crystal display (LCD) to show the date, time, and important messages. You can also use a buzzer and light-emitting diodes (LEDs) for both audible and visible alarms. You can find individual tutorials for all these parts on our How to Use an Arduino page.

This project is highly customizable. You can change the device's physical features, such as:

The project's procedure will show you how to build the device shown in Figure 2, but what exactly you build is up to you!

Terms and Concepts

Questions

Bibliography

Materials and Equipment Buy Kit

Recommended Project Supplies

Get the right supplies — selected and tested to work with this project.

View Kit

This is an engineering design project, so your materials list may vary depending on what features you want to include with your dispenser. Parts may be available in different quantities and prices from different vendors.

Experimental Procedure

Note: This engineering project is best described by the engineering design process, as opposed to the scientific method. You might want to ask your teacher whether it's acceptable to follow the engineering design process for your project before you begin. You can learn more about the engineering design process in the Science Buddies Engineering Design Process Guide.

  1. Build your dispenser. Figures 3 through 5 show several different views of the device. You can choose to make your dispenser using craft supplies or 3D-printed parts if you have access to a 3D printer. Your assembly procedure may vary depending on the materials you use.
    1. Cut a hole in a piece of cardboard so the top of the servo motor fits through.
    2. Glue the servo to the bottom of the cardboard, so the top sticks through the hole.
    3. Build legs to support the four corners of the cardboard.
    4. Place a circular wall on top of the cardboard, centered around the servo. A cardboard tube from the inside of a roll of duct or masking tape works well.
    5. Make dispenser compartments by gluing popsicle sticks together. Use a protractor if you want to measure exact angles. You will need to decide how many compartments you want, which in turn will determine how far the servo should rotate.
    6. Attach the servo horn to the motor (do not use a screw, just push it on) and carefully glue the popsicle sticks to the servo horn. Be careful not to use too much glue, you may need to pull the servo horn off later to make adjustments. 
    7. Cut a pie-shaped wedge in the cardboard, the same size and shape as one of the dispenser slots. 
    8. Build a ramp under the hole so the pills will slide down into a tray.
A rectangular stand with four legs and a pie-wedge shaped pill dispenser on topImage Credit: Ben Finio
Figure 3. Top view of the mechanism. 
 
Square piece of cardboard with four cylindrical legs and a servo motor glued to the center of the cardboardImage Credit: Ben Finio
Figure 4. Bottom view showing the servo glued to the underside of the cardboard.
 
Top view of the pill dispenser platform with the pie-wedge-shaped dispensing mechanism removed from the servoImage Credit: Ben Finio
Figure 5. Top view with the servo horn removed.
  1. Assemble the circuit as shown in Figures 6 and 7. You will need to know how to use a breadboard. Make sure your Arduino is not plugged into USB power as you build the circuit. That will give you a chance to double-check all of your wiring before powering the Arduino on. Note that this diagram assumes you are using an Arduino UNO R4 with a built-in real-time clock. If you are using an external RTC, you will either need a bigger breadboard, or you will have to remove some components (like the buzzer) from the breadboard to make room for the RTC. See our external RTC tutorial for instructions on wiring an external RTC.
    1. LCD connections. Note that pin labels may vary depending on where you bought your board. Pin numbers go from left to right when viewing the screen horizontally, but from bottom to top in Figure 6 since the screen is rotated.
      1. Pin 1 (VSS or GND) to GND
      2. Pin 2 (VDD or VCC) to 5V
      3. Pin 3 (V0) to potentiometer center pin
      4. Pin 4 (RS) to Arduino pin 12
      5. Pin 5 (RW) to GND
      6. Pin 6 (E) to Arduino pin 11
      7. Pin 7 (D0) - not used
      8. Pin 8 (D1) - not used
      9. Pin 9 (D2) - not used
      10. Pin 10 (D3) - not used
      11. Pin 11 (D4) to Arduino pin 5
      12. Pin 12 (D5) to Arduino pin 4
      13. Pin 13 (D6) to Arduino pin 3
      14. Pin 14 (D7) to Arduino pin 2
      15. Pin 15 (LED or A) to current limiting resistor to 5V
      16. Pin 16 (LED or K) to GND
    2. Potentiometer
      1. One outer pin to 5V
      2. Center pin to pin 3 (V0) on LCD screen
      3. Other outer pin to GND
    3.  LED
      1. Positive (longer) leg to Arduino pin 7
      2. Negative (shorter) leg to current limiting resistor to GND
    4. Buzzer
      1. Positive pin to Arduino pin 8
      2. Negative pin to GND
    5. Pushbutton
      1. One side to 5V
      2. Other side to GND through 10 kΩ pull-down resistor and to Arduino pin 9
Breadboard diagram for automatic pill dispenserImage Credit: Ben Finio
Figure 6. Breadboard diagram. Click here to view the circuit in Tinkercad where you can zoom. Note that the Tinkercad circuit does not contain code so nothing will happen if you run the simulation. 
 
Circuit schematic for automatic pill dispenser circuitImage Credit: Ben Finio
Figure 7. Circuit schematic.
  1. Download the pill dispenser example code. Read through the commented code so you understand how it works.
    1. This code is written for the internal RTC on an Arduino UNO R4 Minima. If you are using an external RTC module, you will need to modify the code. We have example code for an external RTC here.
    2. This code is written for a dispenser with four compartments. It automatically rotates the servo 45° once per minute and then sounds an alarm. After the rotation, you need to press the button to confirm that you have taken the medication. After the servo has rotated 180°, it resets to its initial position. 
  2. Upload the code to your Arduino and test it. Watch the motion of the dispenser. You may need to pop off the servo horn (this is why we said not to attach it with a screw earlier) and adjust it so the compartments align with the hole in the cardboard. 
  3. If your device does not work as expected (the servo does not rotate, the LED does not light up, the LCD screen does not display correctly, the button does not work, etc.) you will need to troubleshoot or debug your circuit. This is a complicated circuit with a lot of parts. It is easy to misplace a wire on the breadboard, which can prevent one or more parts of the circuit from working properly. You will need to carefully double and triple-check all of your connections. It also helps to have someone else double-check your wiring, just like you might ask someone else to proofread your writing. Sometimes it can be hard to spot your own mistakes. If you get stuck or frustrated, take a break from working on your circuit and come back to it later. You might notice something that you did not notice before. 
  4. Load some candy into your dispenser compartments and test it again. Make sure there are no issues with your ramp or tray, such as the candy getting stuck or sliding down too fast and bouncing out of the tray. Make adjustments to your ramp and tray if needed. 
  5. Once you have the device working with the example code, it is time to customize your code. The example code dispenses medication one per minute, which works well when testing or for a demonstration at a science fair. There are many things you can change and customize in the code:
    1. How often it dispenses medication. The example code does this once per minute, which works well for testing and for a demonstration at a science fair, but for real-life use you will need to set different times of day. You can do this by adjusting the condition(s) in the if statement that detects the time (seconds == 0 in the example code).
    2. How far the servo rotates. The example code rotates the servo 45° at a time, which works for four compartments. You will need to change the angleIncrement variable if you have a different number of compartments.
    3. The messages displayed on the LCD screen.
    4. The behavior of the alarm, for example whether it beeps a fixed number of times or keeps beeping until you push the button.
  6. Once you have completed testing your device and customizing the code, try some real-world testing if possible. Remember that the device is not childproof and you should not use it with real medication or vitamins in a house with small children. If it is safe to do so, try using it for yourself or someone in your household over the course of a week. Do the automatic reminders make it easier to remember to take your medicine or vitamins? Are there any features you would add or change to your device? For example, what happens if the alarm goes off while you are in another room and cannot hear it? See the Variations section for some more suggestions.
icon scientific method

Ask an Expert

Do you have specific questions about your science project? Our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.

Global Connections

The United Nations Sustainable Development Goals (UNSDGs) are a blueprint to achieve a better and more sustainable future for all.

This project explores topics key to Good Health and Well-Being: Ensure healthy lives and promote well-being for all at all ages.

Variations

  • Build more than one device and run real-life human trials. Have volunteers keep track of how often they missed taking their medication for one week with their "normal" routine and for one week using the automatic dispenser. Does the automatic dispenser help people remember to take their medication more regularly?
  • Try using your device to dispense dog or cat treats instead of medication. Can you use it to train your pet? Can you make it work with different sensors or inputs, such as a PIR sensor (motion detector) or ultrasonic distance sensor? Since the dispenser has an open top, you might want to place it in a high location your pet cannot reach (like a counter or shelf) so it can drop treats onto the floor. 
  • Advanced: make your device send an email or text message notification in addition to sounding an alarm. This can help if you are in a different room and do not hear the alarm. You will need to look up the different options for connecting an Arduino to the internet and sending messages. 

Careers

If you like this project, you might enjoy exploring these related careers:

Career Profile
Just as a potter forms clay, or a steel worker molds molten steel, electrical and electronics engineers gather and shape electricity and use it to make products that transmit power or transmit information. Electrical and electronics engineers may specialize in one of the millions of products that make or use electricity, like cell phones, electric motors, microwaves, medical instruments, airline navigation system, or handheld games. Read more
Career Profile
A medical equipment repairer, or medical equipment technician, has an essential role in the fields of healthcare and engineering. From X-ray machines to electric wheelchairs, the medical equipment repairer can fix a wide array of machinery used in hospitals and clinics. They have detailed knowledge of how machines and instruments are to be maintained, how they function, and how to repair them. Broken medical equipment costs hospitals and providers time, money, and may pose safety risks for… Read more
Career Profile
Have you always loved art? Do you have a good eye for beauty, balance, and form? How would you like to see your designs show up in toy stores? Or in a sporting goods store? Or at a car dealer? Commercial and industrial designers create the shape and form of every type of manufactured good that you can think of—from toys, sporting goods, and medical equipment to high technology products, furniture, toothbrushes, and toasters. They design the form of new products that are as beautiful and… Read more
Career Profile
Have you watched "The Transformers" cartoon series or seen the "Transformers" movies? Both shows are about how good and evil robots fight each other and the humans who get in the middle. Many TV shows and movies show robots and humans interacting with each other. While this is, at present, fantasy, in real life robots play a helpful role. Robots do jobs that can be dangerous for humans. For example, some robots defuse landmines in war-stricken countries; others work in harsh environments like… Read more

Contact Us

If you have purchased a kit for this project from Science Buddies, we are pleased to answer your questions.

In your email, please follow these instructions:
  1. What is your Science Buddies kit order number?
  2. Please describe how you need help as thoroughly as possible:

    Examples

    Good Question I'm trying to do Experimental Procedure step #5, "Scrape the insulation from the wire. . ." How do I know when I've scraped enough?
    Good Question I'm at Experimental Procedure step #7, "Move the magnet back and forth . . ." and the LED is not lighting up.
    Bad Question I don't understand the instructions. Help!
    Good Question I am purchasing my materials. Can I substitute a 1N34 diode for the 1N25 diode called for in the material list?
    Bad Question Can I use a different part?

Contact Us

News Feed on This Topic

 
, ,

Cite This Page

General citation information is provided here. Be sure to check the formatting, including capitalization, for the method you are using and update your citation, as needed.

MLA Style

Finio, Ben. "Make an Automatic Pill Dispenser." Science Buddies, 12 Apr. 2024, https://www.sciencebuddies.org/science-fair-projects/project-ideas/Elec_p105/electricity-electronics/automatic-pill-dispenser. Accessed 30 Apr. 2024.

APA Style

Finio, B. (2024, April 12). Make an Automatic Pill Dispenser. Retrieved from https://www.sciencebuddies.org/science-fair-projects/project-ideas/Elec_p105/electricity-electronics/automatic-pill-dispenser


Last edit date: 2024-04-12
Top
We use cookies and those of third party providers to deliver the best possible web experience and to compile statistics.
By continuing and using the site, including the landing page, you agree to our Privacy Policy and Terms of Use.
OK, got it
Free science fair projects.