I’m the Moon

For Christmas 2012 I received a Moon in my Room. This is effectively a moon shaped night light for kids that includes an IR remote you can use to cycle through 12 unique phases of the moon. It a cool 3D, dome shaped, textured surface representation of the moon. I decided it needed to be a little more aware of the real phase of the moon.

Moon in My Room


It seems that I am not the only person to receive one of these for Christmas or think about doing a little “enhancement”. There are at least two other people who were thinking similar thoughts and documented them early 2013. These had similar thought, use an Arduino and a real time clock to calculate the current phase of the moon and display it. These were implemented to just show the expected phase of the moon for the specific calendar date. My idea differed a bit from these implementations.

I wanted my moon to display the current phase relative to my location. I wanted it to come on at moon rise and go off at moon set. This proved a little more difficult than I first thought. In addition the Moon in my Room is divided into 6 vertical pie segments each with an individual LED. The original moon and the mods that I found were just cycling the LEDs on/off as needed to represent the 12 phases. I wanted to take advantage of the PWM functionality from the hardware I selected and fade each LED on or off which would give me 3072 (12 * 256) distinct phases of the moon. In the end I thought this was going to make it 10x cooler, but in practice I think it only scored a 2x. This is most obvious when my Moon powers on, it goes through a demo mode which shows off this feature.

Following is a video demonstrating the “Demo” mode when it powers up.



The following parts were used (along with estimated costs):





The software was thrown together using the Arduino environment and random information on the internet. I have included some of these resources below, and will hopefully update more in the future.

There are some easy methods for calculating current phase of the moon for a given date. Many approximations can be done and you can still get an accurate enough answer. On the other hand to calculate the actual rise, phase, and setting of the moon for a specific location takes quite a bit more effort. You need to know the time of day. This is done with a DS1307 RTC clock module. In addition you need to know your longitude and latitude. It would have been cool to include a GPS in this project so that it determines its current location. That would have been overkill for something that is likely to hang on the same wall for the majority of its life. So the latitude and longitude is configured in the source code. Easily changed for an occasional move, but not so convenient if I was going to travel around the world with it.

The original moon rise/set code was somewhat convoluted with many global variables. I attempted several times to refactor and make it less convoluted. I did not succeed. Though I think it was better than when it started. In general it seems pretty accurate in comparison to various online calculators for the same info, which often are off by several minutes from each other anyway.

Current Features

  • Lights on/off at Moonrise/Moonset
  • Lights on shows current phase of moon
  • Phase of moon displayed using PWM using 6 leds
  • DST compensation
  • Power on demo sequence
  • USB powered
  • Current status vial USB serial
  • Parameters configured in Sketch

Future Features

  • Configure date/time/location via serial
  • RTC correction configuration and calculation
  • Manual invoked mode that will display phase of next moonrise
  • Clock mode?


Teensy Nano Moon DS1307
PB7/D4  D3 Brown via 100-150 ohm resistor
PC6/D9  D5 Red via 100-150 ohm resistor
PC7/D10  D6 Orange via 100-150 ohm resistor
PD7/D12 D9 Yellow via 100-150 ohm resistor
PB5/D14  D10 Green via 100-150 ohm resistor
PB6/D15  D11 Blue via 100-150 ohm resistor
PD0/D6  A5 SCL
PD1/D5  A4 SDA


Project Firmware


Similar Projects




DS1307 & Arduino




Moon Phase






Moon Rise/Moon Set


DST calculations


Serial clock setting example



Final Thoughts

I completed this project about May 2013, but I am only getting around to documenting it August 2014.  Slacktastic.  I have enjoyed this on my wall.  I find that it makes me more aware of the cycle of the moon, and often I see it lit up and go outside to see what the real moon looks like.  This was a very satisfying project.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>