Automatic Toothpaste Dispenser

by AveryCoding in Circuits > Microcontrollers

188 Views, 1 Favorites, 0 Comments

Automatic Toothpaste Dispenser

Snapshot.png

Lately I have noticed that sometimes I forget whether or not I brushed my teeth on a given day. This is a device that dispenses toothpaste. It also has a light that indicates if the machine was used on that day. This way I can tell whether or not I brushed my teeth because the light will be on. I also wanted to learn how to use the stepper motor so I could make things that require continuous rotation.

Supplies

IMG_0992.jpg
IMG_0993.jpg
IMG_0995.jpg
IMG_0994.jpg
IMG_0990.jpg
IMG_0991.jpg
IMG_0988.jpg
IMG_0996.jpg
IMG_0989.jpg
IMG_0999.jpg
IMG_0997.jpg
PXL_20231108_021754717.jpg
PXL_20231108_021934454.jpg
  • Particle Argon
  • Jumper Wires (like these)
  • Button (these, not the other kind of button)
  • LED (usually comes with the Argon)
  • 330 ohm resistor
  • 28BYJ-48 Stepper Motor
  • 28BYJ-48 Motor Controller
  • Toothpaste Tube (duh)
  • Particle IoT Antenna (usually comes with the Argon)
  • String (I used dental floss)
  • Breadboard (usually comes with the Argon)
  • Weight with hook (I used a tape measure)
  • Metal Pin
  • 2 Brackets
  • Masking Tape/Duct Tape
  • Blocks/piece of wood/base + measuring materials. Any 27cm x 15cm x 8cm rectangular prism. The exact dimensions do not matter. A second 13cm x 6cm x 6cm rectangular prism is also needed. I used wooden blocks.
  • Any consistent 5V power source (I used a USB port on my computer)

Connect the Argon to the Cloud

Go to setup.particle.io and connect your Argon to the device you used to navigate to the site. Follow the instructions there and keep the Argon plugged in during the entire setup process:


When it asks "What type of device are you trying to set up?" select "Device with USB Port"

When it asks for your organization select "My Sandbox"

When it asks for a product create a new product and name it whatever

Wire Everything Together

download (1) (1).png
costume1 (1).png

Arrange your Argon, wires, button, LED, stepper motor, and motor controller according to the diagram above. The colors of the wire do not matter, but having different colors will help you not get confused about what goes into what spot.

Flash Code to the Argon

Go to build.particle.io/build/new


Type whatever you want in the box under "Current App" that says "Title"

Click on "Save"

Click on "Libraries"

Search "Stepper"

Click on "Stepper"

Click on "Include in project"

Click on the option that has the same name as whatever you typed in that box earlier

Click on "Confirm"

Delete all the code in the box on the right

Paste this new code in there instead


#include <Stepper.h>
int led = 7;
int button = 6;
const int stepsPerRevolution = 2048;
#define IN1 2
#define IN2 3
#define IN3 4
#define IN4 5
Stepper myStepper(stepsPerRevolution, IN1, IN3, IN2, IN4);

void setup()
{
    pinMode(button, INPUT_PULLUP);
pinMode(led, OUTPUT);
myStepper.setSpeed(10);
myStepper.step(-stepsPerRevolution);
}


void loop()
{
    int btnState = digitalRead(button);
    if ( btnState == LOW )
{
digitalWrite(led, HIGH);
myStepper.step(stepsPerRevolution);
        delay(4000);
       
}
if (Time.hour() == 5)
{
    digitalWrite(led, LOW);
}
delay(15);
}


Re-plug in your Argon if you unplugged it

Click on "Flash"

Wait until your Argon starts breathing cyan

Unplug it

Plug it into the 5V power source.

WARNING: This must be a 5V power source. If too much electricity flows through certain parts it may destroy them. If you use less voltage, it might just not work, but if you use more it might permanently ruin some of your parts or at least degrade them.

Assemble the Device

IMG_0987.jpg

Take your toothpaste tube and lay it flat on the smaller prism. This will be your base. Then take your brackets and tape them like so, high above the toothpaste tube, using the other prism.

Cut the string to be around 18 centimeters long.

Take your string and tie one end around the round part of the metal pin. Later you will tie the other end around the stepper motor.

Place the stepper motor at the end of the other prism farthest away from the toothpaste tube with the shaft facing the same direction as the toothpaste tube and offset around two inches in the opposite direction of the shaft from the center.

Then, place and tape the two metal brackets (spaced about four centimeters apart) to the top of the prism perpendicular to the shaft of the stepper motor and halfway between the stepper motor and the air above the toothpaste tube.

Thread the metal pin between the small holes of the metal brackets as shown in the diagram above, and Wind the other end of the string around the stepper motor so that it goes counterclockwise. around the stepper motor if facing the opposite direction as the direction of the toothpaste tube.

Hook your weight (tape measure) on the tip of the metal rod directly above the toothpaste tube. When the slightest movement from the stepper motor occurs, the tension force the string begins to apply on the metal rod causes the weight to drop due to the precariousness of its placement.

The toothpaste dispenser is finished. When you would like to use it simply take the cap off of the toothpaste tube and hold your toothbrush very close to the end of the toothpaste tube while pressing the button. Slight adjustments to the positioning of the tube and/or weight may be needed for best results.