LUNCHTIME CLOCK | JAMECO PART NO. 2169512 Experience

advertisement
LUNCHTIME CLOCK | JAMECO PART NO. 2169512
Have you ever wished lunchtime were longer? Well, wish no longer! Thanks to advances in technology, I present to you a
clock that speeds up 20% every day at 11:00 and slows down 20% every day at 11:48. Now you’ll have an extra twelve
minutes of lunch to enjoy. Twelve minutes may not seem like a lot but, to put it into perspective, this is a full additional
hour of lunchtime gained every week.
Experience Level: Intermediate | Time Required: 3-6 hours
Required tools and parts:
Soldering Iron and solder
Computer for programming
Wall Clock
Adafruit Real Time Clock Breakout Board kit: https://www.adafruit.com/products/264
Bill of Materials:
Quantity
1
1
1
2
2
1
10
1
1
1
1
2
1
Jameco
SKU
51262
198791
325139
254801
15405
112300
2157159
1949488
2129334
2144614
2151486
2169521
105111
Component Name
7805T Voltage Regulator
9V Battery
16MHz Crystal
BC547B NPN Transistor
22pF Capacitor
28-Pin IC Socket
1kΩ Resistor
9V Battery Snap
ATmega328P Microcontroller IC
1x6 Position Pass-Through Header
Arduino Uno R3 Microcontroller Board
BC557CG PNP Transistor
2.4" x 3.4" Protoboard
Step 1 – Remove the Clock Movement Pieces
Remove the clock movement from the clock body. This will require removing the front glass face from the clock
as well as the clock's hands. Be careful, you will have to reassemble everything so you don’t want to break
anything.
Step 3: Hack the Movement Pieces
Inside the clock movement is a single coil stepper motor. We want to disconnect the coil from the clock's timing
circuit and attach wires to the coil so that we can control it ourselves. Open up the clock movement and make
careful note of where everything is (or take a picture).
Take apart the movement until the circuit board is free. Locate the contacts on the circuit board where the
motor is located. You will notice that these two contacts have traces that go off to the chip. Use a razor blade
or knife to scratch away at these traces until the connection with the chip is visibly broken. For good measure,
cut away the timing crystal, rendering the circuit more or less useless.
Solder about 6" of wire to each of the motor terminals. When this is done put the whole thing back together. If
there isn’t a spot in the case where you can conveniently slip the wires through you may have to cut a small
hole for the wires to pass through.
Step 4: Putting the Clock Back Together
Once the movement is good and hacked, put the clock back together. Make sure that the hour, minute and
second hand all lined up at 12:00. It will not work properly if not.
Step 5: Real Time Clock Kit
Put together your Adafruit DS1307 Real Time Clock Kit. Need help use this link:
http://www.instructables.com/id/Assemble-an-Adafruit-DS1307-Real-Time-Clock-Kit/
Set the time on the RTC board. As long as you don't take the battery out, you should only need to do this once
(at least for the next five years or so until the battery dies). In-depth instructions for setting the time use this
link:
http://www.ladyada.net/learn/breakoutplus/ds1307rtc.html
Step 6: Building the Circuit
The circuit is pretty simple to build. It is basically what people are calling a "hackduino," a socket for the real
time clock board and a crude H-bridge to control the motor.
Step 7: Program the Chip
You will need to install the RTClib library for your code to work. Use this link for instructions:
http://www.ladyada.net/learn/breakoutplus/ds1307rtc.html
Download lunchtime_clock.zip, uncompress it and then upload the lunchtime_clock.pde code onto your chip.
Here is the code:
// Lunchtime Clock
// by Randy Sarafan
//
// Slows down 20% at 11 and speeds up 20% at 11:48 until it hits 1.
// The rest of the time the clock goes at normal speed
//
// Do what you want with this code. Just make certain that whatever you do, it is awesome.
//
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
int clockpin = 9;
int clockpin1 = 10;
void setup () {
Serial.begin(57600);
Wire.begin();
RTC.begin();
}
void loop () {
DateTime now = RTC.now();
TurnTurnTurn(1000);
if (now.hour() == 11) {
for (int i = 0; i < 1800; i++) {
TurnTurnTurn(800);
}
for (int i = 0; i < 1800; i++) {
TurnTurnTurn(1200);
}
}
}
int TurnTurnTurn(int TimeToWait){
analogWrite(clockpin, 0);
analogWrite(clockpin1, 124); // sets the value (range from 0 to 255)
delay(TimeToWait);
analogWrite(clockpin, 124);
analogWrite(clockpin1, 0);
delay(TimeToWait);
}
Step 8: Putting it all Together
Once everything is programmed you can transfer your ATmega168 chip from the Arduino to your circuit board.
Simply plug in your RTC board into the socket and make sure the pins are lined up correctly before powering it
up.
Go ahead and attach the circuit board and battery to the back of the clock. You can use hot glue, gaffers tape,
even self-adhesive Velcro.
Step 9: Synchronize the Clocks
Put a new ATmega168 chip into the Arduino. Connect the Arduino to the RTC board. Run the sample code
using this link:
http://www.ladyada.net/learn/breakoutplus/ds1307rtc.html
Open the serial monitor. The time displayed here is the time you are going to want to sync your clock to. It was
easiest to set a third clock (I used my computer clock) to be perfectly in sync with the RTC board.
Then, I powered down the Arduino, transferred the RTC board back to my circuit and set the Lunchtime Clock
to a minute later than my computer time. At just the right moment, when the minute changed on my computer, I
powered up the lunchtime clock to achieve synchronicity.
Download