The Automatic Medication Dispencer

FeaturedContest Winner
Picture of The Automatic Medication Dispencer
I wanted to make something for the health contest, but I had no clue where to start until my girlfriend got ill. I noticed how easily she forgot to take her prescripted medication and that made me think. A lot of people, especially elderly people, take a lot medication on a daily basis to stay as healthy as possible. Some of that medication needs to be taken on a exact time, or they don't function as well.
So I decided to make a machine that automatically gives the right pills at the right moment and also sounds an alarm so that the person who needs those pills knows it's time for his or her medication.

It is my first 'big' project that combines a clock/calender, memory and movement.

If you like it, then please vote for it in the Health contest.
Remove these adsRemove these ads by Signing Up

Step 1: What does it do?

Picture of What does it do?

The 'machine' has seven drums (one for each day of the week) with 4 compartments that you can fill with your medication. When filled, you put them back in the machine and connect them to it.

On the front of the machine is a lcd-screen and 2 buttons. There you can set the time and date and program when you need the medication.

When it is time for your medication, the machine drops the correct pills and sounds an alarm until you take the pills and push a button. After that it goes back to "sleep" until the next alarm.

1-40 of 166Next »
janw (author) 3 years ago
Note to everybody who are interessed in the code: I am rewriting the Bascom code for this project and will publish it as soon as I have finished it. But a newborn baby around, they work doesn't go very quickly.
myl123 janw21 days ago

hello there sir. do you have the code of this already? the one that you rewrote? i hope i can get a copy of it. i'll be using this for my project. please send me your code. pretty please! thanks in advanceeeeeee~~

heebey1 year ago
Is it possible at all to get the code for this project?

Thank you.
esoolo1 year ago
The system could also have only one stepper motor, if all the dispensing drums were linked to each other via a pair of pins like the disks in a combination lock:
simjan1 year ago
Hi, just wanted to know what kind of motors are you using?
I take it you are using bipolar stepper motors? also how many phases are each of the motors?
janw (author)  simjan1 year ago
Good question. It took me a long time to figure out what motors they were (I got a batch of them very cheaply for somewhere). The motors have 3 coils with internally connected common. So 4 wires: 1 common and 1 for each coil. They have only 15 steps so they really 'jump' from step to step but that was not a problem in this machine but I wouldn't recommend them for CNC stuff.
Alapakiboy2 years ago
Im helping my friend develop something similar for her senior project and she is planning on using it for grandmother afterwards. Would it be possible if you can help us out with the parts list & how the programming was done. We are planning on adding few more features in it as well and ur help would give us more time to spend on the new features. Your help would be greatly appreciated.
I have built an RC controlled lawmower recently that I can share the instructions for if you like to build one..heeh
Here is my email:
jevans102 years ago
Great Job! Do yoiu mind adding me to the list please?.
please give me the codes...:( for avr...coding is very tedious..going wrong all time..anyone who did it can u give the codes?. id is
need it urgently as i am doing this as my project:)
Rahul163 years ago
hi, i have completed the coding and used PROTEUS Software to simulate the design. but the clock is slow compare to real time clock. can u tell me what frequency oscillator is used for both atmega and ds1307. and also specify current rating for power source for microcontroller and stepper motor driver.
if you have the code for this pill dispenser..will you please mail it to me?need it urgently for my my mail..
please sent it:) need it asap...
janw (author)  Rahul163 years ago
Hi congrats with your simulation. I am still hoping to rewrite the code but my little newborn daughter sucks up a lot of my time so it will take time.

The clockspeed of the atmega is 8Mhz and is generated by the internal oscillator.

The DS1307 uses a 32.768Khz crystal as requested in the datasheet.

I used a 12V 2A supply for this project. I had it lying around and it was enough so I have to recalculate how much the project really needs to give you the exact current
Rahul16 janw3 years ago
thanks for info, so u mean i dont need to connect external oscillator for atmega. and one more thing the main input consist of two supplies (12 v and 9 v). so the current rating is same for both. i thought giving it a advance feature like remote control setting of alarm time using IR Remote and adding a digital thermometer . hows that?
janw (author)  Rahul163 years ago
You do not need an external oscillator indeed. You only need 1 of the 2 supplies, go for 12V, the 9V is for a backup battery.

Adding a temperature sensor is very easy. use an I2C one and just hook it up to the same lines as the DS1307. The datasheet will provide you with the correct way of adressing it.

I have not much experience with IR controles but I am sure that you can figure it out.
Rahul16 janw3 years ago
hi again, actually i m troubling with stepper motor rotation. the program i designed is just for rotating stepper motor for certain angle. and when alarm clicks again it goes back to initial position and rotates for same step angle. i need your help in this part , i want it to remember the position (angle) it had already rotated and start from same angle in place of going to back to initial position (angle). hope u understood my problem. please help me with this part of programing.
janw (author)  Rahul163 years ago
It shouldn't jump back indeed. The steppers I bought came without any information and have 4 leads. By testing them, I found out that they have 3 coils + a common GND and that they have 15 steps in a full rotation. Instead of giving pulses to a stepperdriver, I connected PB0 to PB2 to each coil via a motordriver.

The pinnumbr of the port is placed in variable i and then you can state something like (This is how it works in Bascom):

PORTB.i = 1 to activate a coil and PORTB.i = 0 to deactivate it. By placing it in the variable i, the program will always know what the last coil was and by increasing, you go forward, by decreasing you go back.
cpetrep2 years ago
Could you send me a copy of the specifications?
The sizes of the drums and the code
I am trying to complete a project for my digital II class similar to this.
Thank you
I could really use one of these but I know Diddly about circutry and microcontrollers and etc... good thing I was friends with all kinds of people in HS and I didn't burn my bridges with the "nerds". I just hope one would be willing to make this for me about cheap as free... LOL Great Job!
endl3ss3 years ago
very awesome machine.. Great Job.. i sent you a pm^^..
braidex3 years ago
hi, this is a very nice project...please can you send me the complete code, circuit diagram and how you designed the hardware, anything to help me do this project....this is my email:(
eangrohl3 years ago
Sir, could you send me the schematic diagram of the project, please? Or the circuits you used. I want to know how it is built. We have similar project. Thank you sir.
janw (author)  eangrohl3 years ago

The schematic is in step 4.
Rahul163 years ago
HI. can i use 16f877 microcontroller in place atmega8. suggest me some microcontroller which can replace atmega and please provide pin connection too. please
janw (author)  Rahul163 years ago
I only use AVR microcontrollers so i have no idea if you can use a 16f877. You have to look into the datasheets to see whether they are compatible.
ironmambob3 years ago
I've been a family medicine doctor for over 30 years. This is a great boon to the elderly and cognitively or memory limited. I'll try to make one, or if you have one available buy one for my mother in law.
Katie57573 years ago
Methinks you are reinventing the wheel here..
If someone is so confused that he/she cant remember to take his/her pills, then how the heck is he/she going to work out how to fill up this darned thing.
As an intellectual/electronic exercise yessss.. but you can have a watch tell you when it is pill time.. if that person doesnt know which pill to take, then he/she shouldnt be in charge of anything, let alone such a device...
I take one pill a day.. and that can elude me.. so I have a little chart, that I tick off the minute I swallow it.. on a bit of cardboard.. 7 days.. anyone interested, of course I will share.. but ho hummmmmm.. .. get real.
I am somebody's grandma.. nuff said.
Soose Katie57573 years ago
I've lived through this with four elderly ill people, as have neighbors and friends. A caregiver has a list of meds and when they are to be taken. It's too much for the elderly person (or the ill younger person who might be confused by meds) to remember or to sort through. They might be independent in living skills except for this one problem.

The goal is to keep them as independent as possible, while keeping them safe from overdoses or underdoses. And to relieve the caregiver of extra chores reminding and overseeing the meds.

In all the cases I'm familiar with, the caregiver loads weekly pill boxes (the ones with compartments for AM, PM, etc, and for 7 days/week. It can take 20 minutes to 30 minutes but it's done only once a week, saving lots of time.

There comes a time when the elderly person starts forgetting what time of day to take their pills, then forgets what day it actually is. With all the week's pills laid out in the boxes, there is a problem. Some days they might take multiple days worth of pills; or for several days forget altogether even with reminders and calls. Solving this one problem with an automated dispenser can keep them living independently longer. And save the caregiver multiple trips in the week to dispense pills, or prevent having to hire someone to make multiple trips.

I really appreciate this Instructable. We have the need at the moment and the skills to create this project and it will do all of the above, for a while. If we can do this, confusion about meds will not be the one problem that sends an elderly person into the nursing home prematurely.
For another opinion....

I take about 20 pills a day and have friends that take more and this box would be welcome by many in a similar situation. The problem for myself is that I could never make this box but it would be great if someone could refine it and produce them at a reasonable price.

Thanks for noticing the need and taking the time to come up with a solution.
janw (author)  Katie57573 years ago
Methinks, it's fun to reinvent the wheel from time to time and I never stated that the person who takes the pills should fill the machine.
pls send me the details on the codes and what language do you use? here my email
janw (author)  jimsondefrancia054 years ago
I use Bascom AVR to program
Rahul16 janw3 years ago
could u please tell the algorthim of the program, or flow chart? just i need the concept of behind programming.
staka8 janw3 years ago
would ask you if we could send a detailed project with instructions and how to program the eprom

Can you send me a copy of the specifications also?
my email is
janw (author)  mwagner633 years ago
What specifications other than what is in here would you like to know.
mwagner63 janw3 years ago
The sizes of the drums the code and everything else. You gave an outline not a detailed instruction. no offense it is a great idea.
janw (author)  mwagner633 years ago
I added pdf's with the the drawings of the drums and stuff.
Can you send me a copy of the specifications also?
my email is
spiderx3 years ago
From looking at the animation, it looks kind of iffy. Sure, the meds will dispense, but how to do you make sure only one dosage gets dispensed at a time? It seems to me there can be certain states of the motor where it will have two compartments open at a time.
janw (author)  spiderx3 years ago
it only opens one compartement at a time, but there is indeed a lot of wobbling gooing on. I actually want to build a new one with gears instead of steppermotors so that I can have a more fluent motion.
But I have so many other project gooing on so it will have to wait for a while.
1-40 of 166Next »