Neopixel Street Lantern

As an engineer I love creating things that are functional, but in this project, I went the other way and combined my making skills with a pinch of artistic interpretation to create a model street lantern – and it lights up!

Inspiration struck as I walked down the street whilst on holiday in the Mediterranean. I saw a beautifully designed lantern overhanging a doorway and so I took a picture of it, several pictures actually.

When I got home, I decided to create a light-up replica of the street lamp. You can see the full process and the results in this video below where I document the design and build.

Bill of Materials (excluding laser cuts and 3D prints)

  • Adafruit Neopixel Jewel
  • Arduino Pro Micro
  • 470 ohm resistor
  • 1000 micro farad electrolytic capacitor
  • Screw terminals

3D Prints

The 3D printing for the street lamp was actually really challenging – the print of the lantern body required ‘bridging’ between two separate parts of the print, as you can see here:

Whilst I originally intended to screw/bolt most of the 3D prints together. I ended up resorting to glue… not very glamorous, but it was effective!

You can view the fusion 360 file here: https://a360.co/2RawZ4e

And you can download both the 3D prints files and the laser cutting files (discussed in the next sections) with this arrow…

Laser Cuts

I’ve never done any laser cutting before so I went down my local makerspace – I was shown how to use the laser cutter they had there, and I was even able to buy the wood in a little shop they had. I walked away that night with the finished laser cuts after only an hour or two. This is but a small example of how wonderful the maker community can be!

As well as the wood, I also laser cut some acrylic to create the windows which the light diffuses through, giving a cool glowing look.

If you’d like to download the DXF files for the laser cuts, you can get them by clicking the big blue arrow above.

Circuitry

I normally draw a diagram for the circuit, but to be honest, there was very little to this one. I simply followed the exact details specified on the Adafruit website for working with Neopixels. You can find that detail here: https://learn.adafruit.com/adafruit-neopixel-uberguide/basic-connections

Code

For the code, I programmed up three different routines to flash the lights in cool ways.

1) creepyBlink() makes the lights blink on and off, like the lantern is short circuiting. I wanted to imitate the kind of effect you see in horror films. There is a random delay between the light coming on and off, but there is also random brightness with each flash. I think this creates a fairly realistic effect… although looking at it does give you a headache!

2) breathingRGB() cycles continuously through all the colours of the rainbow. At the same time, it adds a ‘breathing’ effect so that the light fades in and out, as if it’s breathing.

3) strobeLight() is programmed to flash bright colours quickly, like a strobe light you would see at a party, night club or disco.

Some bits of this code are quite complicated, especially the mathematics behind the breathingRGB effect. But don’t worry, you can just copy and paste!

// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library

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

// Which pin on the Arduino is connected to the NeoPixels?
#define PIN            6

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      7

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_RGBW + NEO_KHZ800);


void setup() 
{
  pixels.begin(); // This initializes the NeoPixel library.
}

void loop() 
{
  // uncomment the one you want to see (only one at a time)
  
  //creepyBlink();    // a creepy blionking effect
  breathingRGB();     // a 'breathing' effect whilst cycling through all colours
  //strobeLight();    // a strobe light, like at a party
}

void strobeLight()
{
  //turn the lights on and off, changing colour each tome, with a 0.2 second gap in between.
  setColour(255, 0, 0, 100);
  delay(200);
  setColour(0, 255, 0, 100);
  delay(200);
  setColour(0, 0, 255, 100);
  delay(200);
  setColour(255, 0, 0, 100);
  delay(200);
  setColour(0, 255, 0, 100);
  delay(200);
  setColour(0, 0, 255, 100);
  delay(200);

  setColour(0, 0, 0, 0);
  delay(200);
  setColour(255, 0, 0, 100);
  delay(200);
  setColour(0, 0, 0, 0);
  delay(200);
  setColour(0, 255, 0, 100);
  delay(200);
  setColour(0, 0, 0, 0);
  delay(200);
  setColour(0, 0, 255, 100);
  delay(200);
  setColour(0, 0, 0, 0);
  delay(200);
  
}


void creepyBlink()
{
  // get a random number between 0 and 100
  int randomNum = random(0, 500);
  delay(randomNum);
  float mult = random(100);
  mult = mult/100;  // divide it by 100 so that 'mult' is between 0 and 1

  float redVal = mult * 100;    // 'mult' is used to add rnadomness to the brightness of the neopixels
  float blueVal = mult * 255;
  float whiteVal = mult * 100;
  
  setColour(redVal, 0, blueVal, whiteVal);
  int randomNum1 = random(0, 200);          // create a random delay
  int randomNum2 = random(0, 200);          // I use two added together to make short delays more probable than long ones.
  delay(randomNum1 + randomNum2);
  setColour(0, 0, 0, 0);
}

void breathingRGB()
{
  unsigned int rgbColour[3];

  // Start off with red.
  rgbColour[0] = 255;
  rgbColour[1] = 0;
  rgbColour[2] = 0;  

  // Choose the colours to increment and decrement.
  for (int decColour = 0; decColour < 3; decColour += 1) {
    int incColour = decColour == 2 ? 0 : decColour + 1;

    // cross-fade the two colours.
    for(int i = 0; i < 255; i += 1) {
      rgbColour[decColour] -= 1;
      rgbColour[incColour] += 1;
      
      setColourRgb(rgbColour[0], rgbColour[1], rgbColour[2]);
      delay(30);
    }
  }
}

void setColourRgb(unsigned int red, unsigned int green, unsigned int blue) 
{
  float val = ((exp(sin(millis()/2500.0*PI)) - 0.36787944)*108.0)/255;    // an exponential sine wave which creates the breathing effect

  float redVal = red * val;
  float greenVal = green * val;     // multiply the brightness of each colour by this to create the fading/brightnesing effect
  float blueVal = blue * val;

  setColour(redVal, greenVal, blueVal, 0);
  
}

void setColour(int r, int g, int b, int w)
{
  for(int i=0;i<NUMPIXELS;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, r, g, b, w); // Moderately bright green color.
  } 
  pixels.show(); // This sends the updated pixel color to the hardware.
}

Lessons Learned

The first major lesson I learned is that laser cutting isn’t as scary as I first thought. I’ve never done laser cutting and although I’ve been 3D printing for a long time, I have had a mental barrier to laser cutting… not any longer!

The tricky bit is that Fusion 360 allows you to export a DXF, but you can’t laser cut it directly. Instead, I downloaded the programme Inkscape (which a lot of people use) and import the DXF into Inkscape. You can then just save the inkscape file as an SVG and then it’s in the correct format.

Now you can take the SVG to your laser cutter and get making!

The other part of this project which I haven’t worked with before is Neopixels. I had a nightmare to start with as I chose “NEO_RGB” instead of “NEO_RGBW” in the following line of code.

 Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_RGBW + NEO_KHZ800); 

I needed to add the “W” before the colours I requested actually lit up on the neopixels. However, once I did this, everything went swimmingly from then onwards.

The Wrap Up

So there you have it, one 3D printed street lantern – my most artistic project to date, with new skills of laser cutting and Neopixels learned along the way.

If you have any thoughts or questions, I’d be delighted to hear from you below in the comments.

Happy hacking!

Robin

P.S. thanks for visiting my site 🙂

 

2 Comments

  1. Huidverbetering
    April 18, 2019 @ 7:25 am

    Keep up the good work! Thanks.

    Reply

  2. Pigmentatie
    April 18, 2019 @ 4:14 am

    Looks realy great! Thanks for the post.

    Reply

Leave a Reply