# 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. Dr. Spelgud says:

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

2. bty says:

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

3. Nick Short says:

@david

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

4. Nick Short says:

@bty

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

5. Nick Short says:

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

6. Andrew Parting says:

Yeah, this isn’t very complex trig :/

7. fartface says:

Cant you just draw several thousand pictures in paint?

Math be hard!

8. 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.

9. 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.

10. t&p says:

trig… hard?…

I want to know advanced linear algebra!

11. Just me says:

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

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.