Daily Dose
Project By: Ana Diaz-Young
Intro to Physical Computing Project 2 - Fall 2024
Project By: Ana Diaz-Young
Intro to Physical Computing Project 2 - Fall 2024
Front view of my pill despenser device in its waiting status. You can see the main spinner, ramp with the IR Beam sensors at the end, and the reminding buzzer to the side.
This project was creating a device to both remind myself to take my meds and also have a more visual display to keep track of the amount of pills I have left which is difficult to see in a traditional pill bottle. This device drops one pill every morning through rotating the stepper motor a certain number of steps every 24hrs. This pill is then dropped down the ramp and breaks the IR Beam sensor. If it remains waiting to be picked up for more than 20 seconds, it starts a cycle of buzzing at you to remind you to pick up the pill.
Detailed view of the slide and IR Beam mechanism. I added the curve pieced of cardboard at the end to keep the pills from flying away.
Detailed view of the pill slots and opening of the main component. You can see how the pill drops down into the ramp.
Side view of device to see the placement of the stepper motor. It is mounted to the back of the static shell of the wheel section. You can see the journey path from the wheel to the collection point.
Here you can see an up close view of the wiring for the A4988 motor driver that allows you to control the stepper motor with just two pins in the arduino.
In this video, I show an entire cycle of the device in use. Every 24 hrs, one pill is dropped; then, as it waits for you to pick it up, it reminds you to pick it up every 20 seconds with a period of buzzing noises until the pill is retrieved. This process is repeated every 24hrs. In this video it landed slightly off but in most attempts it does land correctly!
Internal spinning part that holds the meds made with solidworks.
Outer component made with solidworks.
After 3D priniting I realized I needed a way to attach the motor to the component that is spinning so I learned about using a universal mounting hub. In order to use this I needed to use the small drill press in idea to drill screw holes (but there wasn't the perfect bit size so it was a little loose later on but worked decently)
Using the universal mounting hub to attach the stepper motor to the rest of the device.
I was having difficulty getting the stepper motor to spill all the way and I thought it was cause it was just floating in mid air so I tried a couple different ways of supporting it.
Closer view of using the paper towel dowel to hold up the stepper motor.
I also tried using this lego structure as I thought it would more exactly match up with the height of the motor
From the begining of this process I struggled with how to move forward in the sequence of steps cause I felt really overwhelmed with it all. It felt like I couldn't start with electronics without first haveing a physical component to actually be spinning. But it also felt like I couldn't focus on the mechanical design without first considering how it would electronically function particularly with the placement of the stepper motor. This led me to really struggle with moving along in the prototyping period and push a lot of those questions into the final model. This lead to me having to make a lot of "final" decisions without being able to do a lot of the testing to figure things out. For example, I needed to get my 3D printing done at a certain deadline in order to get it printed in time but this forced me to make a decision quickly on how I wanted the mechanism of actually spinning the device to be. As you can see in the pictures above this resulted in me having to use tools such as the mini drill press to adjust my form to make this all work. While I think it would have functioned better (particularly due to the wholes for the screws being slightly to big) if this had been more thought out earlier I think it would have been hard to make these discoveries without working in the final material due to the nature of weight being a key issue in this project. It was both a drawback and important to make these discoveries in 3D printed form. While it may have been costly and time-inefficient, this could have been a great bouncing-off point for further refinement of the physical form in a second iteration. In terms of the process for the electronics and coding I think I was definitely focused on trying not to wait too long on this aspect as I felt I've focused to much on the physical design aspect in previous projects but in reality I learned through this project just how intertwined these components are in creating a function device and rather then focusing so much on trying to do one it should be more of a balanced back and forth making discoveries throughout the project. All of these different trials and errors throughout the project really helped me learn about just how complex some simple processes can be. Throughout the project, I had to use alternatives or redirect my process because of misalignments or other errors. In the end, the main issue with the stepper motor was that it was simply not powerful enough.
"I like that the lid is clear because it allows you to know when you’re close to running out and it’s just cool to see the inner workings"
This was my intention! It was really important for me to make a device that wasn't hiding or limiting the access to information in any way cause that was the whole point. It is both an audio reminder when the buzzer goes off but also the large visible presence was intentional in adding fun and draw attention to something that is often forgotten about. Its not something that I wanted to further stimitized.
Stepper motor is kind of loud – debugging the motor to be more precise for the pill to fall precisely and also have the motor more aligned to the wheel would help probably
I agree it was really tricky working with the stepper motor and I had a lot of issues with the misalignment of stuff. Like I initially wasn't using a big enough motor which not only wasn't powerful enough but it also didn't have a long enough axel to reach through the whole device causing me to waste a lot of time attaching it to dowels and things like that.
I am not the most satisfied with how my project came out cause it feels unfinished, especially with the mix of very high-fidelity components that are 3D printed with the cardboard components. I think in some aspects I satisfied my goal of focusing on the electrical components before moving on to the mechanical design that I tend to focus on but this kinda backfired because it was very difficult to program and make sure my electronics were working properly without having physical components to play around with.
I think I still get very hung up on trying to get everything to work together that I don't spend enough time on the individual components like I was really working on getting the overall look of the ferris wheel but I didn't get focus enough on the important details of like how the motor would interact with the rest of the components making it difficult to play around with later on. I did enjoy getting to use 3D prints that were largely correct though as it made it feel like a more finished project I wish I could have done this for the rest of the device as well to make it more clean overall. I think my limitation of waiting to long to make good progress was very apparent in this project but I have learned to get way better at it for other classes like studio so I think I can apply that to future projects in this class aswell.
I would love to have time to make a more refined version. I think that not only the electronic aspects of making the motor smoother and quieter I think I could include more interactions with reminders about when to call for a refill and things like that. I would spend more time in solidworks creating different location to be able to insert like a rotating calender aspect or some sort of colorful indicators.
/* Daily Dose for Intro Physical Computing Project 2
Every 24hrs (for demo is every minute) the stepper motor rotates the angle of each pill holding cell
this pill then lands between an IR Beam sensor breaking the beam and untill the pill is picked up the buzzer will remind you every 20 seconds.
If the pill is taken it waits to do the next cycle.
arduino pin | role | Description
4 input This is the IR Beam Sensor sending signals back to ardunio.
8 output Sends signal to the buzzer when it is needed.
2 output Tells stepper motor how many steps to take (angle it will spin)
~3 output Tells stepper motor which direction to turn
Some code referenced from:
Toggling Buzzer States: https://forum.arduino.cc/t/arduino-loop-with-buzzer/868057/6
Stepper Motor Guidance: https://courses.ideate.cmu.edu/60-223/f2024/tutorials/stepper
IR Beam Guidance: https://learn.adafruit.com/ir-breakbeam-sensors/arduino
I got some Guidance from TA Ella on fixing my code during the final moments of the project.
Code released to the public domain by the author, 10/25/2024
Ana Diaz-Young, adiazyou@andrew.cmu.edu
*/
#define SENSORPIN 4
#define BUZZERPIN 8
#include <AccelStepper.h>
const int STEP_PIN = 2; // A4988 "STEP" pin wired to Arduino pin 2
const int DIR_PIN = 3; // A4988 "DIRECTION" pin wired to Arduino pin 3
// Create an AccelStepper motor object
AccelStepper myMotor(1, STEP_PIN, DIR_PIN);
unsigned long lastMoveTime = 0; // Time of the last motor movement
const unsigned long moveInterval = 60000; // 1 minute in milliseconds
unsigned long beamBrokenTime = 0; // Time when the beam was first broken
const unsigned long buzzDuration = 20000; // 20 seconds
const unsigned long buzzInterval = 15000; // 15 seconds
bool buzzing = false; // guidance from TA Ella on this
void setup() {
Serial.begin(9600);
myMotor.setMaxSpeed(200); // Set maximum speed
myMotor.setAcceleration(100); // Set acceleration
pinMode(SENSORPIN, INPUT);
digitalWrite(SENSORPIN, HIGH); // Enable pull-up
pinMode(BUZZERPIN, OUTPUT);
digitalWrite(BUZZERPIN, LOW); // Ensure buzzer is off
}
void loop() {
int sensorState = digitalRead(SENSORPIN);
// Check if the sensor beam is broken
if (sensorState == LOW) {
Serial.println("Broken"); //Helps you be able to read on serial monitor to tell if IR Beam is working.
if (beamBrokenTime == 0) {
beamBrokenTime = millis(); // Record the time when the beam was first broken
}
// Check if the beam has been broken for more than 20 seconds
if (millis() - beamBrokenTime > buzzDuration) {
buzzing = true;
}
} else {
Serial.println("Unbroken");
beamBrokenTime = 0; // Reset the timer if the beam is not broken
buzzing = false;
digitalWrite(BUZZERPIN, LOW); // Ensure the buzzer is off
}
// Handle buzzing
if (buzzing) {
static unsigned long lastBuzzTime = 0;
if (millis() - lastBuzzTime >= buzzInterval) {
lastBuzzTime = millis();
digitalWrite(BUZZERPIN, !digitalRead(BUZZERPIN)); // Toggle buzzer state
// Cited from: https://forum.arduino.cc/t/arduino-loop-with-buzzer/868057/6
}
}
// Move the motor every minute if the beam is not broken
if (sensorState == HIGH && millis() - lastMoveTime >= moveInterval) {
lastMoveTime = millis(); // Update the last move time
// Move the motor forward 200 steps
myMotor.moveTo(myMotor.currentPosition() + 300);
while (myMotor.distanceToGo() != 0) {
myMotor.run(); // Keep running until the target position is reached
}
Serial.println("Motor moved forward 300 steps."); // Serial message after moving forward
delay(1000); // Wait for a second
}
// Call run() to ensure the motor can move
myMotor.run();
}