Introduction: Stepper Pomodoro Timer
The Stepper Pomodoro is a desk timer to help one manage their daily task list by breaking each period of work into 30 minute segments. However, unlike a normal Pomodoro timer, it doesn't make you anxious by showing the amount of time left. Instead, it displays the time approximately via which of the three dials is ticking. By not showing the exact time it allows you to actually focus on the task at hand, rather that constantly checking your time left. This Pomodoro is perfect for those needing a light and unobtrusive structure to their task management.
Tools
• Soldering iron
• Wire strippers
• Laser cutter (or sander depending on how you want to create the dials of the timer)
• Drill (I used a drill press to punch holes large enough for the dials)
Materials
• 1 Arduino Uno
• 1 half-sized breadboard
• 3 H bridges (I used DRV8833, a motor shield wold have saved me some time and headaches)
• 3 Stepper motors (I used NEMA 17 steppers)
• 1 Button
• 1 220-1K ohm resistor (any within range is good)
• AC/DC adapter (I used a 12V, probably too large for this amount of steppers)
• Power splitter
• USB A-B wire
• Breadboard wires
• Solder
• Materials for container of timer
• Acrylic for dials
• Nails or metal pins to act as stationary arm of timer
Step 1: Step 1: Soldering and Connecting Circuit Outside of Container
For this step I started by soldering together all of my H bridges (if you purchase the motor shield you shouldn't need to solder these. Once you have an H bridge for each stepper you can check how your steppers are wired.
The NEMA 17s are what are known as bipolar stepper motors, meaning that they have two (rather than one) set of coils within the motor which change polarity to allow for precise movement of the motor. Bipolar steppers normally have four wires and Polar steppers normally have six, this complicated the instructions online a bit. However you can attach a multi meter to two wires and see if they are connected or if they aren't. The NEMA 17 steppers have their wire order in RED, YELLOW, GRAY, GREEN color order, with the red and gray being the first polar pair and the yellow and green being the second polar pair. If at any point the stepper starts twitching rather than completing the expected movement, odds are that your wires are somehow not correctly polarized to their twin or one is disconnected. Each stepper is controlled via four output pins which connect to the DRV8833 H bridges. The wiring order for the input to the DRV8833 is: IN1, IN2, Power, Ground, IN3, IN4. For output purposes the NEMA just connects to the middle four of the six pins in the order of: RED, GRAY, YELLOW, GREEN. Now lets connect power. I have my NEMAs on digital ports 2–13.
To power this I purchased a 12V AC/DC adapter with splitter to be able to power both the Arduino, and all the steppers. WARNING: Don't connect your power and ground wires from the Arduino already receiving power from the port to the breadboard receiving direct power from the AC/DC. It will fry your board. From the 12V adapter plugged into the wall one part of the splitter went straight to the Arduino's port and the other to the positive and negative of the bread board.
Lastly, it is time to hook up the button. One side of the button will need both power (with our resistor spliced in) as well as the output pin soldered on (this can also be done from the breadboard). The other pin will be our ground. These three wires should be plugged into: Power with resistor to 5V, output to A0, and ground to ground all on the Arduino Uno board itself.
From here we should be able to attempt to control the steppers using this basic stepper test code found here. This explanation on Arduino.cc also does a more thorough explanation of bi/unipolar steppers if you need it. Next lets get into the code for the Pomodoro!
Step 2: Step 2: Uploading Code and Adjusting It to Your Needs
Below is the code for my Pomodoro with button, in order to customize it to your setup follow along with these steps:
1. Set how many steps per revolution your personal stepper type has (NEMA 17s have 200 and it is listed in the constant integer called stepsPerRevolution).
2. Set where your button is inputing to in the constant integer caller buttonPin.
3. Set where your arduino should output from to command the steppers (these parts may vary the most between H bridge types as many have different libraries they utilize).
4.Set the stepper speed in RPMs in the .setSpeed (I have mine set for 1 rpm when turning clockwise and 30 rpm when turning anti clockwise).
5. Set how many times you want each of your steppers to turn before it moves on (my steppers count ten minutes, so they rotate ten times at 1 RPM).
6 Set how long you wish for it to rotate backward.
#include
const int stepsPerRevolution = 200; // setting constant of how many steps are in each full revolution of my stepper motors const int buttonPin = A0; // setting constant of my button input
Stepper firstStepper(stepsPerRevolution, 2, 3, 4, 5); // initialize the stepper library on certain pins Stepper secondStepper(stepsPerRevolution, 6, 7, 8, 9); Stepper thirdStepper(stepsPerRevolution, 10, 11, 12, 13); Stepper firstStepperBack(stepsPerRevolution, 2, 3, 4, 5); // reinitialize the stepper library on these pins to be able to reset rpm for when alerting that time has expired Stepper secondStepperBack(stepsPerRevolution, 6, 7, 8, 9); Stepper thirdStepperBack(stepsPerRevolution, 10, 11, 12, 13);
int minutesCounter = 0; // int counting full revolutions of steppers int timerState = LOW; // the current state of the pomodoro timer (HIGH = on, LOW = off/reset) int buttonState; // the current reading from the input pin int lastButtonState = HIGH; // the previous reading from the input pin
// the following variables are unsigned long's because the time, measured in miliseconds, // will quickly become a bigger number than can be stored in an int. unsigned long lastDebounceTime = 0; // the last time the output pin was toggled unsigned long debounceDelay = 50; // the debounce time; increase if the output flickers
void setup() {
pinMode(buttonPin, INPUT_PULLUP); // set constant of button as an input firstStepper.setSpeed(1); // set the speed at 1 rpm for counting 10 minutes per stepper secondStepper.setSpeed(1); thirdStepper.setSpeed(1); firstStepperBack.setSpeed(30); // set the speed at 30 rpm for alerting that time has expired after Pomodoro has completed secondStepperBack.setSpeed(30); thirdStepperBack .setSpeed(30);
Serial.begin(9600); // start serial monitor with a 9600 baud rate }
void loop() { // read the state of the switch into a local variable: int reading = digitalRead(buttonPin);
// check to see if you just pressed the button // (i.e. the input went from LOW to HIGH), and you've waited // long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing: if (reading != lastButtonState) { // reset the debouncing timer lastDebounceTime = millis(); } if ((millis() - lastDebounceTime) > debounceDelay) { // whatever the reading is at, it's been there for longer // than the debounce delay, so take it as the actual current state:
// if the button state has changed: if (reading != buttonState) { buttonState = reading;
// only toggle the timer activaton if the new button state indicates it was pressed // press once to turn on, press again to turn off if (buttonState == LOW) { timerState = !timerState; Serial.print("Timer State is "); Serial.println(timerState); } } }
if (timerState == HIGH) { Serial.println("Pomodoro timer has begun"); if (minutesCounter < 11 ) { //if the current second value is different than the previous value then firstStepper.step(stepsPerRevolution); // turn stepper 200 steps/1 rev minutesCounter++; Serial.print("minutesCounter is "); Serial.println(minutesCounter); }
if (11 <= minutesCounter && minutesCounter < 21 ) { //if the current second value is different than the previous value then secondStepper.step(stepsPerRevolution); // turn stepper 200 steps/1 rev minutesCounter++; Serial.print("minutesCounter is "); Serial.println(minutesCounter); }
if (21 <= minutesCounter && minutesCounter < 31 ) { //if the current second value is different than the previous value then thirdStepper.step(stepsPerRevolution); // turn stepper 200 steps/1 rev minutesCounter++; Serial.print("minutesCounter is "); Serial.println(minutesCounter); }
if (31 <= minutesCounter && minutesCounter < 1031 ) { //if the current second value is different than the previous value then firstStepperBack.step(-1); // turn stepper back 1 step in sequence to appear like all are running simultaneously secondStepperBack.step(-1); thirdStepperBack.step(-1); minutesCounter++; Serial.print("minutesCounter is "); Serial.println(minutesCounter); } } else { Serial.println("Pomodoro timer is off"); } // save the reading. Next time through the loop, // it'll be the lastButtonState: lastButtonState = reading; }
Step 3: Step 3: Contain the Steppers and Arduino If You Wish
I chose to create a parallelogramic form for my clock. This form and the material choices of red oak was inspired by midcentury modern furniture. One part that I had the most difficulty with was fitting the steppers with dials through their portholes to be seen from.