Lunar Phase Clock




About: My name is DJ and I previously made electronic whatsits, 3D-printed thingamabobs, and laser-cut kajiggers for the Instructables Design Studio; now I build and repair puzzles for Escape Industries.

In this Instructable we will be building a dynamic lunar lamp with the Raspberry Pi. With your very own lunar clock you'll always know the current phase of the moon, no matter the weather!

Step 1: History and Theory

Budding astronomer? Recently bitten by a werewolf? Whatever your lunar-phase-knowing needs, the Lunar Phase Clock has you covered! If you're interested in getting started on the build, move on over to the next step. Here we'll talk about the astronomy behind the project.

So what are the phases of the Moon?

Just as the Earth orbits the Sun, so too the Moon orbits the Earth. The Moon is tidally locked to the Earth, which means that because the Moon completes its own rotation in the same time it take to orbit around the Earth, we always see the same side of the Moon. While we may be stuck to the same view of the Moon, the relationship between the Earth and Sun as the Moon completes its orbit is constantly changing. This means that it will be illuminated to varying degrees (or not at all!) and will take on a distinct shape. These distinct shapes are what we refer to as the lunar phases. The Moon completes a cycle around the Earth every 29.53 days; this is referred to as a synodic month.

Step 2: Materials


Raspberry Pi (RadioShack #277-196)
SD card
protoboard (RadioShack #276-168)
(2x) LED strip (RadioShack #55065456) web only
(8x) n-channel MOSFET (3V3 Gate-Source level or lower) Mouser
(8x) 10K resistor (RadioShack # 271-1126)
12V AC adapter (RadioShack #Catalog #: 273-318)
USB wifi adapter (RadioShack #55044156) web only
USB power supply (RadioShack #55075817) web only
Micro USB cable (RadioShack #26-2738)
22 gauge wire (RadioShack #278-1218)
(2x) 4/40 nut (RadioShack #64-3018)
(2x) .75" 4/40 machine screw (RadioShack #64-3011)
(4x) 2" 6/32 screw
(4x) 6/32 nut

Step 3: Configuring the Raspberry Pi: OS and Networking

For these next steps, you'll need to have the Raspberry Pi set up with an operating system and hooked up to a full keyboard/mouse/HD monitor setup or connected to a computer via SSH. Click through the link below to see my brief companion guide for setting up the wireless connection Netgear Wi-Fi adapter. This guide also includes a link to a great Instructable for setting up the Raspberry Pi. Since the RasPi doesn't have a hardware clock, we'll be using the internet as a consistent time source. We'll also need to install a few things in order for us to use the GPIO on the pi. Setting up an internet connection varies depending on how your network is set up. For this Instructable, we'll be using a wireless connection via USB.

Connect the Raspberry Pi to the NetGear G54/N150

Step 4: Configuring the Raspberry Pi: Python Program

Initially, I had considered having the moon-clock pulling the lunar data from the internet over wifi, but as luck would have it, there's an algorithm for calculating the current lunar phase for a given date. Math to the rescue! I found the algorithms here. The particular algorithm we'll be using was written by John Conway, whom you may know as the person behind the cellular automata program "Game of Life." The lunar phase algorithm was written in java, but it was not too difficult to translate this over to python.

Before we can run the Python program we'll need to install the GPIO library and developer headers.

Type the following into the terminal:

sudo apt-get install python-dev

sudo apt-get install python-rpi.gpio

We'll need to install and run the Python program as soon as the Pi boots up. Download the attached program "" and copy it over to the Pi. Make sure it's in the directory "/home/pi" (some info on moving the program over)

We'll make the program into an executable with:

sudo chmod +x

Next we'll need to open up another file. Type in:

sudo nano /etc/rc.local

Comment out any text below by putting a "#" at the start of the line. Below the text type in:

sudo python /home/pi/ &

Hit ctrl+x to save and then "y" to confirm the changes to the file. Now when the Pi boots up our program will run automatically.

Step 5: Build the Circuit: Design

Here is the schematic for our LED driver board. We're using N-channel MOSFETs to connect the 12V powered LEDs to ground. I chose N-channel MOSETSs as this setup has logic "high" pulses from the Pi activating the lights, which was more intuitive to program.

Step 6: Build the Circuit: MOSFETS

Space the MOSFETs evenly on the circuit board all facing the same direction.

Step 7: Build the Circuit: Resistors

Bend the leads of the resistors over so they'll fit into two adjacent holes on the board. Place one resistor from the gate pin of the MOSFET (the leftmost pin when looking directly at it) to the power bus in the middle of the board.

Step 8: Build the Circuit: Terminal Blocks

Place the terminal blocks along the edge of the board so that one of the pins is aligned with the drain pin (middle pin) of each MOSFET.

Step 9: Build the Circuit: Wiring

Using the clipped leads of the resistors, make tiny jumpers with a pair of needle-nose pliers.

Step 10: Build the Circuit: Light Strips

Unroll the LED spool and cut the strip into 16 pieces of 3 LEDs. The strip has copper pads every 3 LEDs for power and ground.

Step 11: Building the Frame: Design

The Lunar Phase Clock is made of stacked sheets of laser-cut plywood for the body and the base. I designed the frame in Illustrator and used an Epilog 120 watt laser to cut out the pieces from 1/4 inch ply and 1/8 inch acrylic. The body plates are stacked together with segmented ribs that organized the light into eight distinct segments. This gives us enough resolution to display the main phases of the Moon. The LEDs lay flat along the back panel and shine light through a sheet of paper that has an image of the Moon printed on it. The paper acts to diffuse the light for more gentile progressions as the segments light up. The body is held together with 4 screws along the top rim. This allows it to be easily disassembled if the LEDs were to be damaged or the face replaced.

The base of the clock is made of three stack pieces of ply that have slots for the body to slide into. The holes are designed with tight tolerances so that the body and base can be held together with a "friction fit." The quarter-circle edge pieces serve to support the weight of the body and hide the wiring and electronics from view.

Download and cut out the attached .ai files.

"MoonFrameComplete" should be 1/4 inch wood. (Note that the ribbed piece should be cut out three times)

"MoonClearPlates" should be 1/8 inch clear acrylic.

Step 12: Glue the Frame

Lay the three base pieces out on a large surface. With course sand paper, remove the unsightly laser burns and charred sap from the edges. Making note of the proper layout, flip the two top pieces over and coat with wood glue. Lay the middle piece upon the base, using the finger holes as a guide to properly align them. Lay the top piece upon the middle plate, using the large rectangular body slot as a guide. Clamp the base pieces together and allow to dry for 24 hours.

Step 13: Moon Graphic

Print out the attached Moon graphic and cut out along the white line. Place the new piece between the two circular pieces of acrylic.

Step 14: Finish the Frame

Lay the solid base plate down with one ribbed piece on top. Using a pencil, outline the inside segments; we'll use this as a guide for properly placing the LED's.

Take the eight elongated LED strips and fish the power wires through the holes near the middle of the base plate. Bend the white wires between each segment so that the strips follow the curves of each segment. Glue the underside of the strips in place.

Place the next two ribbed body plates, followed by the plates with the hole large enough for the acrylic circles. Place the acrylic containing the Moon shape into the body, using the straight edges of the paper to properly align the Moon with the edge.

Place the face-plate over the acrylic sheets. This holds them in place and covers the edges of the paper. Fasten the panels together with the 2 inch screws.

Step 15: Mount Electronics

Mount the Raspberry Pi over the two left holes with the 4/40 screws. Attach the wires from the strips to the driver board, referring to the schematic on step 7 (The leftmost wires while facing the back are attached to the lowest pin number).

Step 16: Power Supplies

Cut off the plug of the 12 volt power supply and plug the wires into the terminal block of the driver board.

Plug the micro USB cable into the Pi and the USB adapter. Plug in the 12 volt supply into the wall.

Step 17: Finishing

The Lunar Phase Clock is fine and dandy on its own, but a touch of color could certainly improve upon its laser-cut appearance. I decided to give my clock a dark stain and a few coats of polyurethane to seal it in. There's lots of open flat panels to coat, so it would make a great canvas for some custom artwork too.

2 People Made This Project!


  • Barbeque Challenge

    Barbeque Challenge
  • Beauty Tips Contest

    Beauty Tips Contest
  • Growing Beyond Earth Maker Contest

    Growing Beyond Earth Maker Contest

46 Discussions


4 years ago

Great instructable man! This is my version, made with Arduino!

15 16:05.jpg15 16:05.jpg

1 year ago

Dude! Tell me this is in the Raspberry Pi challenge. I would totally vote for you!


2 years ago

Excellent job bro.


3 years ago

I really appreciate this instructable. I've made everything but it seems I might have used the wrong transistor. I am only getting about 6.2V out. I'm using the IRF840 "IR" Power MOSFET N-Channel 8A 500V. The link to the transistor is dead. Am I supposed to be using an IRF510?


Whoa. Really cool! DJ, you are very smart and this is an awesome project.


4 years ago on Introduction

Am I blind or are the dimensions for the plywood not listed? I'm only afraid to do this project because of the woodwork needed.

1 reply

Reply 4 years ago on Introduction

Theyre not explicity stated since it was orignally cut with a laser. If you download the vector files on step 11, you can see the dimensions when you open them up. Send me a message if you need anything else!


5 years ago on Step 8

Not to be an ass about this, but your original parts list on the first page doesn't mention the terminal blocks... They do make for a nicer install.


5 years ago on Introduction

They sell a lunar phase nightlight at Chinamart,as well as the other warehouse type stores.Its a little larger than this design,but what I was getting at is you could take the electronics out of the nightlight,and put them into his design which is a lot more pleasing to the eye,the nightlight can be programmed with the true moon phase,and they even have a remote for around $11.00.

4 replies

Reply 5 years ago on Introduction

Cool idea! It could definitely be made with other such parts. This clock does show the true moon phase already though.


Reply 5 years ago on Introduction

Right,all I suggest was using the guts out of the Moon phase light in the making of
his design.Like I said,the night light has all the LEDs ready to install in his design and with the remote that comes with it,one can program it to do true moon phase,or go through them fast,or whatever.It would make it easier for those who would like to do this Able without having to do any of the electronics.


Reply 5 years ago on Introduction

two things. First, great thought on using the ready-made lunar clock..... and second thing... I laughed pretty hard at the word Chinamart. ..... much better than WallyWorld.


Reply 5 years ago on Introduction

No doubt bro,I would like to know how may Made in America items they have in any given store,not including food items I would bet no more than a couple dozen,what do you think?


5 years ago on Step 17

Love it,.. Sadly not many of us have a laser cutter readily available... Ever consider offering the parts as a "diy kit". For a reasonable price I'd love to be able to build this. Also just a thought adding into the algorithm a way to calculate lunar eclipse's and add some red LED's to activate at the eclipse to give the proper coloring.

4 replies

Reply 5 years ago on Introduction

I dig your idea of the red LED's for during an eclipse. that would be too cool ..... as for the use of laser cutters.... you could use a reciprocating saw, or some sorta' LARGE hole-saw (the can shaped bit put in a drill to cut door knob holes etc.) to cut the hole in the wood body of the clock... then for the curved ribs within the hole you could carefully bend some cheap aluminum angle-iron. aluminum strips are pretty cheap and can be found at most hardware stores or farm supply stores. :)


Reply 5 years ago on Introduction

This is an amazing and ingenious project. Using lights and no moving parts to indicate the moon's phases is awesome. At 65 years of age comments like jtetreault2 left do sadden me. I have made projects from wood, metal, glass and paper for most of my life long before laser cutters were invented. At its most basic the clock case is a woodworking project that can be constructed by hand with simple woodworking tools and time. At one time the worth of a project was judged by the hand work and craftsmanship that went into it. Today it is more the idea and the programming skills that are admired. Nothing wrong with that but let's not forget that many projects can still be made without a laser cutter and CNC machine.


Reply 5 years ago on Introduction

It saddens me too... My grandfather was a carpenter / cabinet maker... Sadly he passed before I was old enough for him to pass on any of his knowledge in that field to me. I'm going to try but lacking the knowledge and skill it's going to be hit or miss i'm afraid.


Reply 5 years ago on Introduction

Wow, thank you very much! Yes, this most certainly could be made using traditional woodworking techniques. I had a rather short timeline to build this, so I turned to the laser cutter. There are definitely many other ways it could be made!