Introduction: BookClock - Arduino-based Clock in a Cardboard Box

This is the most recent (and cheapest yet) member of the Wise Clock family.

(As a quick recap, the other members of the Wise Clock family are, so far, the glass-domed Wise Clock and Wise Clock 2. They are "wise" because, along with the time, they also display quotations.)

This clock is made with just three major elements:
1. Wiseduino (with RTC and EEPROM on board);
2. 8x32 LED matrix display from Sure Electronics;
3. cardboard box as enclosure.

A few other required components are:
- a tilt sensor (or tilt ball switch);
- a USB cable, to power the clock.

Step 1: Assembling Wiseduino

Wiseduino is an Arduino clone with an on-board real time clock (DS1307) and EEPROM (24LC256).

Wiseduino can be bought as a kit here. The kit contains the following components:
- PCB (black);
- ATmega328P microcontroller programmed with the bootloader;
- 28-pin socket for the ATmega328P chip;
- 16MHz resonator for the microcontroller;
- DS1307 real time clock, with 8-pin socket;
- 24LC256 EEPROM, with 8-pin socket;
- 32768Hz crystal for the RTC;
- CR1220 coin battery and battery holder;
- 6-pin right angled male header (FTDI connector);
- 40-pin female header;
- 4 resistors 10K;
- 4 decoupling capacitors 100nF;
- 2N2222 transistor;
- power micro switch;
- 2-pin polarized male header (power connector);
- power jack with cable.

To assemble Wiseduino, follow these mini-steps:

1. Solder the IC (integrated circuits) sockets first. Place them correctly, so their notches match those in the silkscreen.
(This will be helpful later, when the ICs are to be inserted into their respective sockets; their notches should match those in the sockets, which match those in the silkscreen, got it?)
2. Solder in place the battery holder. (photo 1)
3. Solder the power connector, then the FTDI connector. (photo 2)
4. Solder the micro switch on the pads. Since this is an SMD (surface mounted device), use this technique: put some solder on one of the pads; place the switch over the pads, then solder the pin which is over the "loaded" pad. Once in place, solder the remaining pins.
5. Solder the four identical (10K) resistors in their places. These are the only resistors on the board.
6. Solder the four decoupling capacitors. Again, they are the only capacitors on the board.
7. Solder the 15MHz resonator.
8. Bend 90 degrees the 2 pins of the small cylindrical crystal (32768Hz), then solder it so it is parallel and close to the board. (photo 3)

At this point, we would have a few more steps to a complete assembling. But, for this project, we don't solder the female headers and neither the transistor.

What is left to be done is:

9. Insert the integrated circuits in their respective sockets, matching the notches (as mentioned above).
10. Insert the coin battery in its holder.

Next, we need to "hack" Wiseduino a bit, to install the tilt switch and to solder the ribbon cable for the display.

Step 2: Modifying Wiseduino

At this point we need to modify Wiseduino to include the tilt switch, and also to accommodate the ribbon cable that goes to the display.

Let's start with the ribbon cable.
First, we need to cut the traces to D0 and D1, close to the header. The position of the cuts is indicated with a yellow arrow in photo 2. (These two traces are the first two from the top of the board.) Once D0 and D1 in the connector are disconnected from the microcontroller, we will re-connect them to Vcc (5V) and GND, respectively, by soldering two wires as shown in photo 3.

Next we will solder the ribbon wires themselves, in the holes intended for the female (extension) headers.
These are the wires that need to be soldered (the red wire of the ribbon is numbered as 1):
- wire 1 to D8;
- wire 5 to D7;
- wire 7 to D6;
- wire 15 to D1 (which became connected to GND earlier);
- wire 16 to D0 (which became connected to Vcc earlier).

For the tilt switch, two mini-steps are required:
a. Solder a 10K resistor between A0 (analog 0) and Vcc. In my case, the closest Vcc was pin 8 of the DS1307;
b. Solder the tilt switch between the same A0 (analog 0) and GND, making sure the cylinder is at a 45 degree angle to the board. Thus, when the board is laying, the ball in the tilt switch makes contact between the 2 pins. When the board is standing, the ball drops to the other end of the cylinder (that does not have wires), leaving the switch's contact open.
This is illustrated in photo 4.

At the end of this step, the board should look like the one in photo 1.

You can now insert the connector of the ribbon cable into the LED display. Make sure that on the display, the switch no. 2 is in the ON position and the three others are in the OFF position.

Step 3: Programing Wiseduino

The code library, tested with Arduino IDE 18, can be downloaded from here.
The content of the zip file is shown in the photo 1.

NOTE: An FTDI cable (or FTDI breakout) is required to upload sketches to Wiseduino.

There are three mini-steps to program the clock.

1. First, we need to set up the real time clock. (photo 2)
Load ds1307_test.pde and, in setup(), modify the lines that send the "set time" command.
Compile, then upload the sketch. The first time thisk sketch runs, it will set the real time clock to with the given hour, minute etc.

2. Second, we need to load the quotation file to the external on-board EEPROM. (photo 3)
Next, load eeprom_quotes.pde sketch, compile it and upload it. At this point Wiseduino is waiting to receive characters on the serial port. To send the characters, run (double click on) WriteFileToCom.vbs. This is a VB script that reads the content of the quotes.txt file (provided in the zip) and sends it over the serial port. Make sure that the line referring to quortes.txt specifies the correct absolut path. At a baud rate of 9600, it will take about 10 minutes to transfer the whole file (and write it to EEPROM).

NOTE: The VB script is intended to be used on Windows.

3. Third, upload the main sketch that reads the status of the tilt switch and displays the time and the quotations. (photo 4)
Load the BookClock.pde, compile and upload. This sketch contains the actual code that reads the EEPROM and RTC and displays the quotations and the time.

Test the sketch by tilting the switch one way or the other and notice how the display changes based on the orientation.

Step 4: Building the Cardboard Enclosure

Find a cardboard box that fits the LED display on the "spine" side (as if the box would be a book standing).

The box I used is one from adafruit, used for shipping kits/components.

Cardboard is easy to cut with an xacto knife. Draw the contour of the LED display (photo 1), then cut along the lines (photo 2). The opening should fit the display snuggly (photo 3 and 4). Then use some tape (I used electrical tape) to stick it to the inside of the box (photo 5).

Step 5: Encasing the Electronics and Powering Up

With the LED display in place, we need to stick the Wiseduino board to the bottom of the box somehow. For this purpose I used velcro with sticky tape on the other side (can be bought at dollar stores).

We will power BookClock through a USB cable, preferably at least 5 feet long (so I power socket is always within reach).
Cut the "type B" or "type miniB" end of the cable, leaving the cable with the "type A" connector (that gets inserted into the computer's USB port).

Now cut (using the same xacto knife) a small opening for the cable, on the side opposite to the display, as shown in photo 1. Insert the cable through the hole.

Separate the inside wires so that the red and black ones are accessible, then solder each one to the corresponding red and black wires of power cable coming with Wiseduino (photo 2). Insulate the soldered connections with electrical tape.

To secure the cable, place a wire-tie around the cable and on the inside, close to the hole, as shown in photo 3 (bottom left corner).

To power up, plug the USB cable in either the computer's USB port or in a USB power adapter, the kind used for charging iPhones/iPods (can be bought on ebay for less than US$2), shown in photo 4.

The BookClock is now ready to use and show.