Arduino Based Phases Of The Moon Lamp

Whether you are learning about astronomy, or you just like to keep track of the next werewolf cycle, this moon phase lamp is for you! This guide shows you how to make an Arduino based lamp which displays the phases of the moon. It is a really unique looking lamp which can also be used as a night light.

It can be programmed as a display piece cycling through the moon phases or it can be programmed to follow the lunar cycle and depict the phases of the moon in real time.

This project assumes you know the basics of Arduino programming, otherwise read our article on getting started with Arduino.

What You Need To Build A Phases Of The Moon Lamp

  • Micro USB Cable To Power & Program The Lamp – Buy Here
  • Arduino Gemma Microcontroller – Buy Here
  • 12 Neopixel LED Ring – Buy Here
  • Hot Melt Glue & Glue Gun – Buy Here
  • 3D Printer & White ABS Filament To Print Moon Lamp – Buy Here
  • Soldering Iron & Solder – Buy Here
  • Some Scrap Thin Insulated Wire

How To Build The Phases Of The Moon Lamp

The guide is broken up into three steps, 3D printing the lamp components, assembling the electronics and finally programming the Arduino.

3D Printing The Lamp Components

The Moon Phase Lamp is made up of 3 main parts. The zip file containing the 3D print models can be downloaded here –  3D Print Files.

3d print moon lamp half

The first thing you will want to do is print the two halves of the moon as they take a while to complete. You should get good results printing it in white ABS with no supports. Print it with 4 shells (Layers) to keep it transparent, but thick enough to hold it’s shape.

3d print moon lamp divider

The divider in the middle divides the light into 12 parts. It is also designed to work perfectly with the 12 LED Neopixel light ring. For best results, print it with black filament to better separate the light between phases but if you only have white filament then that works fine as well. The white plastic, however, bleeds light to the other sections quite a bit. Make sure to keep the doors of your 3D printer closed and the fans off during this print as it is very thin and therefore susceptible to warping.

Assembling The Electronics

The electronic connections are really straight forward, you need to just solder the terminals of the LED ring onto the terminals on the Arduino using a few short pieces of wire.

arduino to led ring connections

Following the schematic you will find that it’s pretty easy to wire the moon lamp.

soldering the LED ring onto the Arduino, up close

The USB cable can be either directly connected to the battery terminals or simply plugged into the micro USB port if you wish. If it is plugged into the micro USB port, it will also allow you to upload different sketches without taking anything apart. Just plug it into your computer to change the Arduino code.

feed the USB cable through the top moon half

Whatever you decide to just just don’t forget to feed the cord through the top moon half or you will have a hard time putting it together later.

Programming The Arduino

Now it’s time to load the code onto the Arduino. Plug your USB cable into the micro USB port on the Arduino. Upload the sketch below and the lights should start to work. This code simplistically runs through the lunar cycle with a 1 second delay between phases.

To get the code to simulate a true lunar cycle, you need it to cycle through the 24 LED phases in a lunar cycle of 29.53 days by increasing the two delays to – 29.53 x 24 x 60 x 60 x 1000 / 24 = 106 308 000 milliseconds duration between LED light changes.

// The DIY Life
// Michael Klements
// 04/05/2017

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

int pin = 0;  //Which pin is the Neopixels attached to

int numPixels = 12;  //How many NeoPixels are attached to the Arduino

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(numPixels, pin, NEO_GRB + NEO_KHZ800); //When we create the pixels object, we need to tell it how many pixels there are and which pin it is connected to.

void setup()
{
  pixels.begin();
}

void loop()
{
  for (int i=0 ; i<numPixels ; i++)
  {
    pixels.setPixelColor(i, pixels.Color(255,255,255));   //Send RGB colour values for white
    pixels.show(); //Change the LED ring to the selected colour
    delay(1000);
  }
  for (int i=0 ; i<NUMPIXELS ; i++)
  {
    pixels.setPixelColor(i, pixels.Color(0,0,0)); //Send RGB colour values for black/off
    pixels.show();
    delay(1000);
  }
}

You can download the basic moon lamp code here – Moon_Simple.

Assemble The Lamp

Now comes time to assemble the lamp. Place the light divider inside of the bottom half of the lamp. Now set the electronics into place. You will notice that there is a ring that holds everything in place. Make sure to align the LEDs so that one fits between each divider.

install the LED ring into the divider

Once the electronics are in place add a dab of glue to hold it in place. Then support the board as you feed the top half through the cord. Add some hot glue around the edges of the moon halves and carefully put them together.

glue on the top and bottom moon halves

If you don’t get the alignment correct the first time, simply heat the glue up with a hair dryer or heat gun and you should be able to move it slightly.

Now plug the moon lamp into your computer and watch the cycles of the moon.

plug in your moon lamp

moon phase lamp

This post is based on Moon Phase Lamp by The Modern Inventor and is modified and used under the Creative Commons license CC BY NC SA.

Michael Klements
Michael Klements
Hi, my name is Michael and I started this blog in 2016 to share my DIY journey with you. I love tinkering with electronics, making, fixing, and building - I'm always looking for new projects and exciting DIY ideas. If you do too, grab a cup of coffee and settle in, I'm happy to have you here.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest posts

Khadas Mind 2 Unboxing & Review

Over the past two years, I've tried two of Khadas' single board computers which were aimed at being compact and low power computers for...

Elegoo Mars 5 Ultra Unboxing and Review

The Mars 5 Ultra is the latest revision to Elegoo's successful Mars series of SLA printers. Its product page advertises an impressive set of...

LincStation N1 All-SSD NAS by LincPlus, Unboxing & Review

Today we're going to be taking a look at the LincStation N1, a 6-bay all-SSD NAS by LincPlus. It is marketed as being great...

Related posts