Building an analog meter clock with Atmel and Adafruit

Adafruit’s Trinket is a tiny microcontroller board built around Atmel’s versatile ATtiny85 (MCU).

“We wanted to design a microcontroller board that was small enough to fit into any project – and low cost enough to use without hesitation,” Adafruit’s Limor Fried (aka LadyAda) explained. “[It is] perfect for when you don’t want to give up your expensive dev-board and you aren’t willing to take apart the project you worked so hard to design.”

Although the Trinket launched in September, the ATtiny85-powered Trinket has already tipped up in a number of projects including a sound-reactive color LED organ, IR control device, Tap Tempo and a temperature/humidity sensor. Today, we’ll be talking about building a Trinket-powered analog meter clock. As Adafruit’s Mike Barela notes, the Trinket is a perfect fit for clock projects, as the platform is small and easy to hide behind a larger display.

“Clocks don’t need a lot of logic, this example only has maybe 20 lines of code, [while] adding a digital display via I2C is possible using seven segment or character-based displays (with the library code posted for other projects),” Barela wrote in a detailed tutorial on the subject. “This [specific] project interfaces Trinket to the the Adafruit DS1307 real-time clock (RTC) breakout board to form a clock. But in a twist, the display is done using two analog meters. One for hours, one for minutes.”

According to Barela, the Trinket is capable of outputting to a meter without digital to analog converters.

“Trinket has pulse width modulation (PWM) on three of its pins. The meter uses a moving coil inductance movement, acting to average the indication of current flowing through it,” he continued.

“If you have narrow pulses, the average voltage it sees is lower, thus the current is lower for the fixed resistance attached to it. For wide pulses, the meter sees nearly the supply voltage and will stay around the full scale. This circuit varies the pulse width sent to the meters proportional to the hour of the day and the minutes after the hour.”

For two meters, says Barela, two of the three PWM pins on Trinket will be used (the third is also an I2C pin connected to the clock module). Although there are many ways to display the finished product, Adafruit decided to go with the meters “free-floating” in a colorful box, rather than a cabinet or plexiglass display.

To kick off the project, Barela recommends Makers first unpack their Trinket. Those using a breadboard or Perma-Proto board will want to solder on the (provided) header pins. After unpacking the DS1307 kit and building the circuit, Makers are instructed to modify the Arduino IDE to work with Trinket by adding the hardware definition file, the avrdude.conf file – while changing the ld.exe program from the 2008 dated version to the 2009 dated version and installing the driver for USBtinyISP appropriate to your operating system.

“To prepare the Trinket for other programs, you will want to first load the Trinket Blink sketch into the Arduino software then load it onto the Trinket to verify everything works well. You must press the hardware reset button on the Trinket then quickly press upload in the Arduino software to upload a sketch,” Barela added. “If you get an error, try the reset-upload process again. If you continually cannot load the blink sketch, check to make sure the Trinket is connected (without any wires connected to pins #3 and #4) and the Arduino IDE software has all the required changes.”

Interested in learning more? Be sure to check out Adafruit’s detailed analog meter clock tutorial here.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s