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.


  1. David Rysdam says:


  2. Dr. Spelgud says:

    cameras make me shutter with fear, math just makes me shudder. Math, and illiteracy.

  3. bty says:

    shutter with fear because of the math ?
    this is the most basic of basic trigonometry.
    A twelve year old can do this.

  4. Nick Short says:


    Both, actually. Trig to get the angles for the hands and geometry to draw the shapes.

  5. Nick Short says:


    I think it was more about drawing the objects than determining the position of the hands.

  6. Nick Short says:

    Nevermind…I did something I rarely do and failed to read the content of the link, first. You both are correct!

  7. Andrew Parting says:

    Yeah, this isn’t very complex trig :/

  8. fartface says:

    Cant you just draw several thousand pictures in paint?

    Math be hard!

  9. Dax says:

    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.

  10. Agent420 says:

    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.

  11. t&p says:

    trig… hard?…

    I want to know advanced linear algebra!

  12. lcuk says:

    Hey, that is awesome!
    I have something similar, however my analog clock is actually hand drawn! :)
    It is a cool effect, have a glance here: http://liqbase.net/20110323_002.jpg

  13. Just me says:

    More useful would be to implement proper vector/matrix math with the mcu. Then anything graphical would be much easier.

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


Get every new post delivered to your Inbox.

Join 97,791 other followers