Note: When I first wrote this guide, using CircuitPython 3.x, the RGB LED on the Gemma M0 would light up with a solid color when a program was running. That is no longer the case with more recent versions of CircuitPython. However, you can download and install CircuitPython 3.1.2 for the Gemma M0, and the program below will work and make a nightlight.

If you want to use the Gemma M0 for anything else, such as the Nightlight Pro, use the latest version of CircuitPython for the Gemma M0, which you can find here.

When you plug in a Gemma M0 running CircuitPython 3.1.2, the DotStar RGB LED on the board pulses green if there's no code.py program to run. If there is a code.py, it shows a solid color.

Pulsing green was a little spooky for this nightlight, so I wrote a code.py to run forever:

while True:
    pass

That's it, that's the whole nightlight program -- the shortest project code you'll ever see! To use, just copy and save it as code.py on your CIRCUITPY drive.

Then I plugged it in to an AC adapter with a short USB cable, but if you only have a long one, you could  bunch it up with a twist tie.

This simple nightlight was good enough for our houseguests, but let's make a nicer one. Onward!

This guide was first published on Jul 07, 2018. It was last updated on Jul 07, 2018.

This page (Nightlight Basic) was last updated on Jul 06, 2018.

Text editor powered by tinymce.