Introduction: Simple Dispenser
This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com).
This is an instructable for the construction of a motion-activated, stepper-driven dispenser. The dispenser is a very basic design allowing a range of objects >9mm to be dispensed at you motion activated convenience.
Required Parts:
3-D printer
Arduino Uno
Breadboard and Jumper Wires
Servo
Stepper Motor
Sonic Sensor (HC-SR04)
Notes:
This project was completed under time constraints with one hand(broken hand). While it is fully functional I would say it is ~70% complete. Some notable additions and fixes I would like to implement include:
-My biggest absent feature is a transparent view of the propeller housing, my original intent was a view of the dispensing like the quarter gumball machines that let you watch it roll all the way down, I lacked time/motivation to find an adequate solution
-Better designed holding box, something perhaps removable from the main box to allow easier refills
-Cleaner placement of the proximity sensor opening
-Redesign of the drop off from the propeller housing, something attached to the lid would allow more room for cable management and better modulation
-Googly eyes and paint to make it look appealing
All problems aside enjoy this short tutorial and let me know of some more improvements to make in the comments!
Step 1: Print the Parts
All parts are to scale and ready to print. Simply download and print. These files are mostly original, with the exception of the sensor mount: which was found through another students parts.
Step 2: Upload the Program
This program is an original solution and may contain redundancies or unnecessary lines. It is quite straightforward and reflects functions learned in class. Simply copy and paste the below text into your arduino IDE, then compile and upload to your Arduino Uno board.
/**********************Copy here***********************************************/
//candy_code
//mitchell beall
//code for a simple dispenser, designed for make course Spring 2018 semester
#include "Stepper.h" #include
//stepper pins 1 - 4 wired to arduino pins 10 - 13
#define pin1 10
#define pin2 11
#define pin3 12
#define pin4 13
//h2rso4 pins
#define echoPin 9
#define triggerPin 8
#define servopin 7
const int stepsPerRevolution = 200;
//two objects used to control physical stepper and servo
Stepper myStep(200, pin1, pin2, pin3, pin4);
Servo myservo;
void setup()
{
//random baud i like
Serial.begin(115200);
//initialize proximity sensor
pinMode(echoPin, INPUT);
pinMode(triggerPin, OUTPUT);
//connects to servo object to the appropriate pin
myservo.attach(servopin);
//sets default angle
myservo.write(75);
//helps timing errors
delay(1000);
}
void loop()
{
//speed to aid one full rotation
myStep.setSpeed(45);
//usual logic to gain reads from sensor
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
//convert sensor distance to centimeters
int distance = pulseIn(echoPin, HIGH);
distance = distance/58;
Serial.println(distance, DEC);
//if within 20cm
if(distance < 20)
{
//opens latch for a second then closes to default angle
myservo.write(110);
delay(1000);
myservo.write(75);
//rotates the stepper one full cycle in 2 seconds
myStep.step(1000);
delay(1000);
}
//extra delay to help avoid errors
delay(1000);
}
/******************End of code************************************************/
Step 3: Wiring the Circuit
Following the attached diagrams should result in a powered and grounded circuit.
The arduino analog pins 5v and GND lead directly into the board, as well as power and ground for all 3 components. The servo is attached directly to digital pin 7 with the sensor trigger 8 and echo 9, while the stepper is pin 10 -13. The last order mixed up will result in an opposite spin for the propeller. Notice all digital pins attached directly to the devices, with the breadboard acting only as a power line.
Step 4: Assembly
For optimal wiring follow the pictures, and at the end secure the lid, then you are ready to go! Some wiring may be rearranged for efficiency.
Note my servo mounts had snapped during assembly and i used duct tape to secure it. Any adhesive will do fine.
Detailed instructions:
Start with all cables un-wired except the proximity sensor
1. Place board at bottom
2. Mount sensor inside its bracket onto the holes near the empty side
3. Place the servo appropriately under the top hole, then wire
4. Screw down the stepper motor oriented like in the picture then wire
5. Put the guard on top
6. Push the propeller down gently onto the stepper, it fits snugly
7. Insert the breadboard and rest of cabling, organizing as desired
8. Attach battery
9. Screw down the lid
At this point the dispenser will be ready and operational
Step 5: Dispensing
1. Load the Top
2. Swipe by the sensor on the right side.
3. Enjoy!