Light your way with Arduino...



tl;dr Alex Eames https://rasp.io/ has launched another Kickstarter and this time it is an Arduino night light project that anyone can hack. Head over and get yours now.

When I first took my steps into electronics it was with an Arduino Uno. MrsP bought me one for Chrsitmas and I spent a few days tinkering.

But there was a problem..I had no idea what I was doing, nor did I have a goal in mind, beyond blinking an LED.

I needed a project to focus on, and this came in the form of PIR sensors, those geodesic domes that detect movement. Then I learnt about LDR (Light dependant resistors) then neopixels (I love neopixels and blinky lights.)

But all of this took a while, and I needed lots of help.

Getting to the point

Serial Kickstarter Alex Eames (Alex has created many successful Kickstarters from rulers to LED light shows) sent me a package out of the blue and in it was this.

A Night Light?

Yeah a Night Light, powered by an Arduino Nano clone on top of a custom PCB. On the PCB we have eight APA102 RGB LEDs, these are similar in operation to Neopixels, but much better. Alex has experience of these LEDs via his InsPIring Kickstarter in 2017.

Also present on the board are a buzzer, always useful and noisey!



An LDR to measure light levels.



And a PIR (Passive Infrared) sensor to detect movement.



Everything is enclosed in a laser cut (me thinks Alex used his K40 laser cuttter for this demo unit) case that also acts as a diffuser for the APA102 RGB LEDs.

This is a really nice unit, well built and a platform for experimentation thanks to an easy to understand Arduino example sketch...which I proceeded to "enhance" by including two lines to start a serial console and then post the light levels from the LDR to the serial console. This enabled me to fine tune the if conditional that is triggered when the light level is low and someone moves. Well this is a night light after all!

if (pir == 1 && ldr <= 150 

changed to

if (pir == 1 && ldr <= 450

So that is came on at dusk.

I then modified the code used to turn all of the APA102 RGB LEDs "white"

        for(int i=0; i<NUM_LEDS; i++){
           leds[i].setRGB(white_bright,white_bright,white_bright);
        } 

So that I then had a quick colour cycle before the light turned on to guide you in the dark...why...? Why not?:)

        for(int i=0; i<NUM_LEDS; i++){
            leds[i].setRGB(128,0,0); //RED
        }                                     
        FastLED.show();
        delay(200);
        for(int i=0; i<NUM_LEDS; i++){
            leds[i].setRGB(0,128,0); //GREEN
        }
        FastLED.show();
        delay(200);
        for(int i=0; i<NUM_LEDS; i++){
            leds[i].setRGB(0,0,128); //BLUE
        }
        FastLED.show();
        delay(200);

I also modified the code to give two "beeps" when the unit is turned on, to indicate that it was working. As the buzzer is connected to pin 2, all I needed to do was turn it on, delay, turn it off, delay, turn it on, delay, turn it off.

     digitalWrite(2, HIGH);
     delay(200);
     digitalWrite(2, LOW);
     delay(200);
     digitalWrite(2, HIGH);
     delay(200);
     digitalWrite(2, LOW);

Interested?

Alex's Kickstarter is now live and you can stake your claim on a Night Light and use it to inspire someone to create their own project using the Arduino.