Electronics/IT veteran and Arduino n00b: Cylon Eye

Hi all, let me begin my introductory post in this forum by saying that boy do I ever feel stupid for tossing out all my breadboarding stuff 30 years ago thinking well heck I'm never gonna use this crap again. :rofl:

In fairness my old wire-wrapping tool still isn't likely to see any more #30 anytime soon. But the year's not over yet!

Anyway my questions are going to boil down to hardware choices and horsepower.

I intend to get my feet wet in Arduino (?) land by installing about 30cm of 144/m density WS2812B variety RGB LED strip (around 43 LEDs depending on how the strip and the cabling sits) behind the face shield of a Roof "Boxxer" motorcycle helmet. I hope to use Peter Gullberg's Knight Rider "Kitt" scanner code as least as a template if not outright for the LED scanning.

In the interesting of keeping the solution small and convenient, I was thinking of buying an Arduino Nano for the breadboarding and testing process and a Nano Every for the final product. The hardware case and battery will probably live taped behind the helmet.

The last time I was toying with this idea (pre-COVID) I had read some things about the device speed being a problem for the addressable LED scanning function, but that may have been a Raspberry-pi thing, not Arduino. I don't recall for certain. Will the Nanos be OK or am I setting myself up for frustration? Anything in particular you folks think I need to be warned about?

Thanks in advance for reading and wish me luck!!! I wonder if I can finish this before Halloween...

1 Like

It sounds like a good pick to get started. I believe the regular Nano would do just fine and they are inexpensive so buy several as you will probably fry some. The most important thing to remember is the Arduino is NOT a power supply. Plan on powering your leds externally, it can be the same power supply just do not run the power through the arduino. Yes my wire-wrapping tool still gets used. I set up with awg28 instead of awg30, it still works great.

When you are inside your house, at night, with the lights on, can you see out the window?

Code for your WS2812

1 Like

Just about the smallest arduino you can find will be OK. Probably stick with something that requires +5vdc, not 3.3v, since the LEDs also require 5v

Here's some code that gives a "cylon eye" or "knight rider kit" effect.
It wont compile as-is until you move sections into void setup() or void loop() as required, I've copied this out another working sketch of mine.
Some of the code could be more elegant or efficient, but it works OK for me.

You can see the count up and count down through the LEDs has 3 trailing LEDs of reduced brightness. Without that you dont get a nice effect of incandescent bulbs fading

#include <Adafruit_NeoPixel.h>

// set the length of the NeoPixel shiftlight strip
int LED_Count  = 8;
// NeoPixel LED pin
const int LED_Pin = 10;
// use a 330 ohm resistor in series with this pin and your neopixel data line
// power the Neopixel strip from a seperate 5v supply and 100uf cap
// common ground

// Define the NeoPixel strip object:
Adafruit_NeoPixel strip(LED_Count, LED_Pin, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)

// INITIALIZE NeoPixel strip
// and turn OFF all pixels ASAP
strip.begin();
strip.clear();
strip.show();    

// Put this in a loop if required

// Cylon eye effect
for (int i = 0; i < LED_Count + 3; i++)
	{
	delay(50);
	//strip.setPixelColor(i + 1, strip.Color(24, 0, 0));
	strip.setPixelColor(i, strip.Color(255, 0, 0));
	strip.setPixelColor(i - 1, strip.Color(50, 0, 0));
	strip.setPixelColor(i - 2, strip.Color(12, 0, 0));
	strip.setPixelColor(i - 3, strip.Color(0, 0, 0));
	strip.show();
	}
for (int i = LED_Count + 3; i > -4; i--)
	{
	//strip.setPixelColor(i - 1, strip.Color(24, 0, 0));
	strip.setPixelColor(i, strip.Color(255, 0, 0));
	strip.setPixelColor(i + 1, strip.Color(50, 0, 0));
	strip.setPixelColor(i + 2, strip.Color(12, 0, 0));
	strip.setPixelColor(i + 3, strip.Color(0, 0, 0));
	strip.show();
	delay(50);
	}

// uncomment if you are going to use the neopixels for some other function
/*
strip.clear();
// actual number of LEDs is 0 to LED_Count
LED_Count = LED_Count - 1;
*/

Hi Gil, thanks for the vote of confidence, LOL. Well at least Nanos are inexpensive enough to buy a few. And if I screw up badly, more are probably available same-day on Amazon. Or I can wander over to Micro Center and see what they have.

Yes, I've noted the source/sink current capacity of the Nano. Not worth pushing my luck. I had a feeling someone would mention that. Glad y'all are paying attention!

Hi @xfacta ! Thanks for the reassurance on the Nano's capability. And thanks for the code tip!!! Yes, the fading effect is an absolute MUST!

Yell out if I can help - I'm fully in touch with the importance of the Cylon eye effect :slight_smile:

In my case I use it once during start up ( void setup() ) of my shift-light function of automotive gauges.

An Arduino Leonardo Tiny would do if you only need a limited range of inputs and puts - they are quite tiny as the name suggests

1 Like

Hi @xfpd , thanks for the source code tip.

It took me a moment :joy: but I do get your concern about the LED strip on the face shield. Hopefully the glare from the LED strip against the polycarbonate will be manageable. Won't know for certain until I try. I also have different face shields I'll be experimenting with (clear, smoked, metalized, etc.).

I do plan on using IP67 LED strips with black backing and plan to use Blacktak to attach the strip to the face shield.

Blacktak is the shiznitz by the way.

I'm a city boy here (NYC to be exact) so "at night", well, some of these streets seem brighter at night than during the day!

Some experiments go well. Some, not so well. We shall see...

Yes, the Leonardo looks smart for this!

#include <Adafruit_NeoPixel.h>

int LED_Count  = 43 ;
const int LED_Pin = 2;

Adafruit_NeoPixel strip(LED_Count, LED_Pin, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.clear();
  strip.show();
}

void loop() {
  for (int i = 0; i < LED_Count + 3; i++) {
    strip.setPixelColor(i, strip.Color(255, 0, 0));
    strip.setPixelColor(i - 1, strip.Color(50, 0, 0));
    strip.setPixelColor(i - 2, strip.Color(12, 0, 0));
    strip.setPixelColor(i - 3, strip.Color(0, 0, 0));
    strip.show();
    delay(50);
  }

  for (int i = LED_Count + 3; i > -4; i--) {
    //strip.setPixelColor(i - 1, strip.Color(24, 0, 0));
    strip.setPixelColor(i, strip.Color(255, 0, 0));
    strip.setPixelColor(i + 1, strip.Color(50, 0, 0));
    strip.setPixelColor(i + 2, strip.Color(12, 0, 0));
    strip.setPixelColor(i + 3, strip.Color(0, 0, 0));
    strip.show();
    delay(50);
  }
}

I'm not sure if I understand the reasoning behind using two different boards that are totally different from a hardware perspective. Also note that those boards are not really known for their low power consumption; not sure if that will be an issue. A Pro Mini is smaller and power consumption is lower.

Note that it's not a Leonardo but a Leonardo Tiny.

I don't see a reset pin / button on that board so I would suggest that you do the development on an Arduino Leonardo or SparkFun Pro Micro.

Hi @sterretje , I thought the Nano Every was generally identical to the Nano except for the breadboarding convenience of the Nano having the headers pre-mounted. Upon a second look this apparently was wrong. Good catch. I just went back to re-check the page I got that from and sure enough it says the Every has more RAM and and more program memory. And has a version with pins available!

My thought process yesterday was that whatever would work on the Nano should have no issue on the Every.

GREAT tip about power consumption, thanks. It seems that the controller's power consumption may be a pittance compared to the addressable LED strip but it wasn't even on my radar. Shame on me. Depending on packaging and my cell choices (coin cell stack? NiMH AAAs? Energizer Lithium?), every mA may count. I haven't made hard decisions on packaging yet - I need to visualize the parts from in front of me first - just the way my head works. I also planned to make current measurements at the strip as I'm testing to see how scanning sequences affect overall power consumption. I should probably keep a second meter handy for controller power consumption.

Thanks everyone for making sure I pay attention to everything!

I hate when other folks leave things open-ended, so, progress report...

All the parts are in. Stupidly cheap US$16 breadboarding kit from Amazon full of wires, buttons, discrete components, etc. (funny how I tossed out a breadboard like 20 years ago thinking "oh I'll never use that crap again), a new bench DC power supply to replace the one I built 45 years ago :roll_eyes: , a $10 controller gadget for the LED strips just for easy QC, USB tester, handful of Arduinos, etc. One light strip is a couple of weeks late but the IP67 one is here. Which is really funny, basically an IP65 WS2812B strip inside a rectangular cross-section rubber thing. :rofl: Sheesh.

Preliminary power consumption tests show that a pack of three Energizer lithium AA batteries should power everything for maybe 4-5 hours at a full-brightness setting with xfpd's code here. Maybe an hour and change with AAA batteries so that ain't gonna work for me. But I'll be playing with different brightnesses. And maybe will add a small pushbutton to the final product (wait, is there such a thing?!) to set the brightness while in use. Given the juice required by the LEDs, I think the controller's power is the least of my worries.

Side-notes...

I can bring the voltage on the LED strip down to about 2.05 before it finally gives up, so that lines up well with the discharge curves for the batteries.

Haven't tested yet how far down the Arduino can go. But if I can find one with an acceptable Vin of 3VDC~5.5VDC that would probably be helpful, avoiding needing to use more batteries and a regulator.

The LED strip definitely wants a resistor on the Arduino's data output so I used a 330 Ohm piece from the cheapo breadboarding kit. And I haven't cooked any Arduinos. Yet.

Oh, one last thing, my TV is on an antenna here. And I lose reception when the Arduino fires up.

Thanks everyone for your help and guidance - it was SUPER helpful!

And, absent-minded professor update #2...

As I was using strip.setbrightness() to make brightness adjustments to the RGB strip and seeing little resulting change in current draw, it hit me... My power requirement readings were with a full 1-meter strip of LEDs. Snipping that bad-boy down to size is gonna help. A LOT. Stay tuned, LOL.

And, wow, the strip.setbrightness() function is VERY non-linear! I decided at least for now that the subroutine below works well enough. Repeated presses set it to 127, 63, 31, 15, 7, then back to 255. I call it from within each of the two loops that cycle the LEDs back and forth. So far no performance issues.

int buttonState = 0;
int stripBrightness = 255;
const int Button_Pin = 7;
void CheckButton()
{
  buttonState = digitalRead(Button_Pin);
  if (buttonState == HIGH) {
    stripBrightness = stripBrightness = stripBrightness / 2;
    if (stripBrightness < 5) {
        stripBrightness = 255;
    }
    strip.setBrightness(stripBrightness);
    delay(150); // Avoid bounce and give visual feedback
  }
}

Important engineering note:

The Nano Every that I happened to be experimenting with right now, ran fine with 5V on the +5V pin, all the way down to 3.1V... then the processor chip let its magic smoke out when I got down to about 3V.

:roll_eyes: :rofl:

In my opinion that is sort of sub-optimal behavior for a low-voltage condition but I'm just funny that way.

I might start another thread on this matter.

Now to go solder up a set of headers on a nekkid spare...

Thanks for "listening"!

Another update... Battery life and smoke test 2.0...

A three-pack of L91 (Energizer AA Lithium) went 22 hours before hitting 1.39V each, which is the far side of where it should sharply drop off. And I still haven't cut the other 100 LEDs off the strip yet. :joy: Since I'd only be wearing this a few hours at a time this seems like very good news. This also means I need to re-check my math because this is more than twice the life I expected and makes AAA batteries practical.

When the voltage did fall off the lithium cliff, no smoke. Yay. LEDs stopped in their tracks (read as: Arduino stopped functioning) when the pack hit about 3.68V.

Note, this was with the battery pack on Vin instead of +5V.

It's worth mentioning again that even with the L91 batteries down to 1.2V they'd be perfectly happy to offer almost 3A until their last dying gasp. So no smoke makes me happy.

FYI and very relevant: Just before the Every's quitting voltage, the +5V pin was reading 3.20V. And after the Every quit it fell to zero. So it seems like it could have its own low-voltage cutoff.

Probably my last update on the subject....

With 44 LEDs on the strip, a pack of three AA Energizer Lithium (L91) gave me about 27 hours. A pack of three AAA Energizer Lithium (L92) gave me about 21. Quite a bit better than I initially anticipated! So I went with the AAAs.

The LED strip wound up tucked into the top edge of the helmet's eye port and were barely even visible to me there, much less distracting. The bigger obstacle is using an iridium face shield at night. Thankfully while most of my 60 year old body feels like it's 90, my eyes still think I'm 20.

I ran out of time to fuss with the details due to a family emergency and packaging wound up being two tiny rubber bands holding the Arduino and the data line drop resistor to the battery case. So much for ESD cautions... :rofl: Next year I'll have a plastic something neatly piggy-backed on the battery case.

Given the light loss through the iridium face shield, the brightness control wound up omitted in the "final" product. (as if anything in this hobby is every really final). Which meant commenting out the code for the button because the Arduino does get somewhat pist if you tell it to watch a pin and leave off the pull-down resistor. That had me guessing for a few minutes thinking one of the power connections was NFG.

For next Halloween I think the LED strip could actually be a bit shorter. And I'm going to play with the code to try to deal with the sensation of the scan coming to a complete halt at each side. It needs to double back on itself a little I think.

And I think I'd like to try a layer of some diffusing plastic to blend the light trail a bit.

Have fun everyone! And thanks again for helping out!!!

That looks pretty cool. Your gonna find out things are way less expensive than they were 30 years ago. A lot of the tools are free when back then they were hundreds if not thousands. These boards are so easy to get up and running compared to back then.

1 Like

That is one reason to set the pinMode to INPUT_PULLUP, wire the button to ground, and watch for a LOW when the button is pressed.

1 Like

Good advice for the future @david_2018 , thanks!