About this 3D model
Second Arduino Clock Updated version of the Second Arduino Clock Adjustable with two buttons Here is a clock with hours, minutes and seconds 2 stepper motors, driven by an arduino nano and an RTC for accuracy. It includes two buttons to set up the hands at the right time See it here: The build video: https://youtu.be/9eBKjtjRucM Clock and prototype: https://youtu.be/4Mqo7j9JnSA All the parts are easy to find on Amazon, Ebay and others. For the wiring, look for schematics.pdf Here is the arduino code: /* Jacques favre:drive 2 stepper motors to power a clock using a RTC for acuracy2 buttons to adjust time1 button: move secondsother button: move hours and minutes2 buttons: move hours and minutes backIncluding work from:# http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay # https://learn.adafruit.com/adafruit-arduino-lesson-16-stepper-motors/arduino-code# Adafruit RTClib [](https://travis-ci.com/adafruit/RTClib)This is a fork of JeeLab's fantastic real time clock library for Arduino.For details on using this library with an RTC module like the DS1307, PCF8523, or DS3231, see the guide at: https://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/overviewWorks great with Adafruit RTC breakouts:- [DS3231 Precision RTC](https://www.adafruit.com/product/3013)- [PCF8523 RTC](https://www.adafruit.com/product/3295)- [DS1307 RTC](https://www.adafruit.com/product/3296)To install, use the Arduino Library Manager to search for "RTClib", find "RTClib by Adafruit" and install the library.Please note that dayOfTheWeek() ranges from 0 to 6 inclusive with 0 being 'Sunday'. I use unixtime from the RTC with an interval of 1 second Every 1 second ask stepper motor to move x steps(seconds)Every 1 second ask stepper motorB to move x steps(hour and minutes)And blink the onboard led Drive a stepper motor to power a clockUsing kuman small stepper motor 5V 1/64 gearing and provided driver For the second hand:The exact gearing is 1/64with 32 steps at motor, that is 2048 steps at shaft revolution, divided by 60 for 1 second motion (6 degree)2048 x 1/60 = 34.133 steps/secondThe exact move would be 34.133333 steps per secondSo move 34 steps, keep track of reminder, and add 1 step when remainder bigger that 1Print info to console to keep track of progress Minute and hour motor calculationSame idea exept, ration 2:1 to minute, 1:6 to hourThat gives the 1:12 between minute and hourFor the minute:(the "second" formula / 120)(60 second in 1 minute, but ratio 2:1, so 120 )2048 x 1/60 x 1/120 = 0.284444 steps/secondSo move 0 steps, keep track of reminder, and add 1 step when remainder bigger that 1, move a stepPrint info to console to keep track of progressThe minute hand will move every 4 seconds or sometime after 3 seconds 2 buttons to set time: button 1 to move seconds button 2 to move hours/minutes forward both buttons to move hours/minutes back */ //FOR RTC//Date and time functions using a DS3231 RTC connected via I2C and Wire lib#include #include "RTClib.h"RTC_DS3231 rtc;//FOR stepper#include // constants won't change. Used here to set a pin number:const int ledPin = LED_BUILTIN;// the number of the LED pin/built in led //2 button to adjust time const int button1pin = 7; // the number of the pushbutton pin, one for secondconst int button2pin = 8; // the number of the pushbutton pin, one four minutes and hours // 32 step motor // second motorStepper motor(32,9,11,10,12); // hour and minute motorStepper motorB(32,3,5,4,6); //and variable that will changeint ledState = LOW; // ledState used to set the LED //int button1State = 0; // variable for reading the pushbutton status//int button2State = 0; // variable for reading the pushbutton status unsigned long previousSECOND = 0; // will store last time LED was updated// constants won't change:const long interval = 1; // interval at which to blink (1 seconds) //For secondsconst float absoluteSteps = 512.000000/15; //2048 x 1/60 = 512/15 = 34.133333 steps/secondconst float extraStep = absoluteSteps - 34; // 0.133333 leftover remainder// variablesfloat totExtraStep; // to keep track of decimal part of stepsint totSteps; //adding all stepsint seconds; //display seconds counter // for hours and minutes//2048 x 1/60 x 1/120 = 64/225 = 0.284444 steps/second//neeed take ratio of gears, minute hand to motor ratio 2 to 1float absoluteStepsB = 64.000000/225; //0.284444 steps/second, calculated steps per second const float extraStepB = absoluteStepsB - 0; // 0.284444 leftover remainder// variablesfloat totExtraStepB; // to keep track of decimal part of stepsint totStepsB; //adding all steps// to print time to consoleunsigned long time; //SETUP****************************************void setup () { // set the digital pin for LED output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: //pinMode(buttonPin, INPUT); //for sec pinMode(button1pin, INPUT_PULLUP); //pinMode(buttonPin, INPUT); //for min and hour p