Medical Tunes - Arduino Powered Medicine Box
by RedKing in Circuits > Arduino
8 Views, 1 Favorites, 0 Comments
Medical Tunes - Arduino Powered Medicine Box

Do you often find yourself forgetting to take your medication? If so, this is the box for you! This medicine box plays a short, programmable song that makes taking your meds a more memorable experience. No longer will you be wondering if you took them already, just think of that quick little tune!
Supplies
For this project, you will need:
- An Ardunio board (this one is an Arduino Uno)
- Peizo speaker
- Jumper wires
- Button
- Switch
- Servo motor with screw
- Popsicle Sticks
- Stl files for 3D pieces (feel free to use cardboard if you don’t have a 3D printer!)
Here's the files we made:
Set Up the SparkFun Board

Get out your Breadboard and Arduino set up like this:
Wiring

Here’s a digital example of what the board will look like made in Tinker cad. Use this as a reference for your physical board.
Upload Code to Board
We've made the code for you! Feel free to change the angle of the servo depending on how far you want your box lid to open
//Medbox code
#include <Servo.h>
//pins
int switchpin = 10;
int speakerpin = 8;
int servopin = 7;
int resetbutton = 9;
Servo myServo;
bool hasplayed = false; //play sound once
void setup () {
pinMode(switchpin, INPUT_PULLUP);
pinMode(resetbutton, INPUT_PULLUP);
pinMode(speakerpin, OUTPUT);
myServo.attach(servopin);
myServo.write(0); // Start at 0 degrees
//switch turn on
}
void loop () {
int buttonvalue = digitalRead(resetbutton);
//reset
if (buttonvalue == LOW) {
hasplayed = false;
}
int switchvalue = digitalRead(switchpin);
if (switchvalue == HIGH && !hasplayed) { //switch is on
tone(speakerpin, 392, 750);
delay(300); // G
tone(speakerpin, 493, 750);
delay(300); // B
tone(speakerpin, 587, 750);
delay(300); // D
tone(speakerpin, 739, 750);
delay(300); // F#
tone(speakerpin, 784, 450);
delay(500); // G
//rotate servo
myServo.write(120);
delay(500);
noTone(speakerpin);
delay(5000);
myServo.write(90);
hasplayed = true;
}
}
Begin Box Assembly










- Print CAD Pieces
- Align top lid with main box hinges
- Insert hinge rod into lid holes
- Cut open top of main box (this allows room for the board to sit inside)
- Add small platform to catch lid
- Add supports and tape down servo motor and add a lever to open the lid
- Add levels on either side of the box openings and insert Arduino board
- Drill hole in side for battery pack
- Drill hole into top of the cut off part of the box and attach to the levels
- Insert battery pack
That's it!
Test the Code
Depending on how far open you want to open your box, you will want to change the angle the servo motor goes to. We recommend starting at 0 degrees, opening to 120, and then going back down to 90 to close the lid. It does not take a lot of power to open the lid, but using bigger angles makes it easier. Be careful of using too much power continuously, as that will burn out your servo.
Showcase Your Project!
After everything is set up, this is how your box should function. Feel free to change the color of the box, add decorations, or anything else to customize it to your heart's desire!