Learn the geometry to draw an analog clock on a graphic LCD screen

Does the image of the clock above make you shutter with fear because of the math you’d need to use to recreate your own version of the project? We certainly understand that High School geometry is becoming a very distant memory, but it’s really not as hard as you think. [Janw] built this analog clock using a graphic LCD and he’s done a great job of explaining the concepts behind it.

The hardware he’s using is pretty standard for an electronic hobby clock; an ATmega16, graphic LCD, DS1307 real-time clock, and supporting hardware like a potentiometer, resistors, and buttons. The code is written in Bascom, but like we said, [Janw] explains the concepts behind drawing the hands on the clock so you can recreate this with any microcontroller or software language you prefer. We  recommend grabbing a calculator and some blank paper. It took us a few tries to brush the cobwebs out and really grasp what he’s doing with each equation.

13 thoughts on “Learn the geometry to draw an analog clock on a graphic LCD screen

  1. Drawing the objects is simple

    Consider that you have two points A and B. The equation that gives you the funtion of a straight line between these points is

    y = Ay + (By – Ay) / (Bx – Ax) * (x – Ax)

    It isn’t any more complicated than that when you cut off the handwaving.

  2. Agreed… sad day when basic trig is considered a hack.

    But – I’ve been using BASCOM AVR for years, it’s freakin awesome. As it creates compiled code, it’s no slouch and the cases I feel compelled to code in C are far and few between.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s