Pill Dispenser

by bgarcia184 in Circuits > Microcontrollers

244 Views, 1 Favorites, 0 Comments

Pill Dispenser

unnamed (1).jpg
pill dispenser

It dispenses pills or whatever else you feel like dispensing

Supplies

Building materials:

Corrugated cardboard

2 SG90 Micro Servo

1 wooden popsicle stick

Wall wart

Power adapter

External power source

Particle Argon


Tools:

X-acto knife

Hot glue gun

Hot glue sticks

Ruler

Writing utensil

Making External Case and Pill Tube

IMG-0352.jpg
IMG-0353.jpg

Use the x-acto knife to create four 6 in by 2 in rectangles out of cardboard then use the hot glue the 6 inch side together to create a square prism.

Use the x-acto knife to create four 6 in by 1 in rectangles out of cardboard then use the hot glue to glue the pieces together as you did previously.

In the smaller prism, cut a hole spanning 1 side of the prism making it about an inch tall and about an inch from the top. Repeat this step about an inch below the original hole that you made.

Creating Foil Paddle Buttons

Cut two squares of the same size out of cardboard, the size doesn't matter as long as they are the same. Take a piece of solid core wire and strip the casing off the end to expose the metal.

Curl the end of the wire into a coil and affix the wire to the cardboard square using hot glue, taking care to not hot glue over the exposed metal.

Repeat the previous step on the other cardboard square.

Using hot glue, tightly affix aluminum foil over the cardboard square in such a way that the wire is touching the foil from underneath.

Repeat the previous step on the other cardboard square.

Cut a third cardboard square, roughly the same size as the first two, and then cut a hole in the middle to make a cardboard frame

Glue both paddles to opposite sides of the cardboard frame

Affixing Servos

Cut both ends off a wooden popsicle stick in such a way that the piece you cut off matches the length of the servo fin you are using

Repeat the previous step and use hot glue to attach one end of the popsicle stick to each servo

Line up the servo with the hole cut in the previous step and use hot glue to affix it; make sure that the servo fin is facing the interior of the square prism

Attaching Inner Chute to Exterior Case

IMG-0355.jpg
IMG-0356.jpg

Use hot glue to affix one side of the internal chute to the interior of the larger square prism. Which side you choose to affix is up to you as long as it isn't the one you previously attached the servos to.

Wiring the Breadboard

unnamed (1).jpg

Code

Servo myServo;
Servo myServo2;
int button = 5;
void setup(){
    myServo.attach(2);
    myServo2.attach(3);
    myServo.write(10);
    myServo2.write(20);
    pinMode(button, INPUT_PULLUP);


    
}


//Nothing changes in the setup function


void loop()
{
//Read the state of the button
int btnState = digitalRead(button)

//Check if button is low, if true:
;if(btnState == LOW)
{
    if(myServo.read() <= 20)
    {
        myServo.write(120);
        delay(500);
        myServo.write(10);
        delay(600);
        myServo2.write(120);
        delay(500);
        myServo2.write(20);
    }
    if(myServo.read() >= 120)
    {
        myServo.write(10);
        delay(500);
        myServo.write(120);
        delay(600);
        myServo2.write(20);
        delay(500);
        myServo2.write(120);
    }
}
delay(200);

}