Larson Scanner, Anyone?

Maybe somebody has already done one this way, but I cannot find anything similar based on ‘Search’.

First, there are a lot of LED back-and-forth, running lights jobs out there; many of them claiming to be “Larson scanners”. But a “Larson scanner” needs a trail of dimmer lights following the leading light. Whether he was the inventor as such I’m not sure, but when Glen Larson did these for Battlestar Galactica (Cylons) and Knight Rider (KITT), he used light bulbs and the bulbs’ incandescence (their residual glow) made for the trailing effect.
LEDs go on/off rapidly, there’s no continuing glow-down when they go off, no gradual fade out.

So - how could that be done with LEDs?

Whip out your Arduino? Good start, but still.
Use the PWM pins? There are only six.
Charlieplex? Stop already.
Glom some “library”? Not me.
Off-board circuitry, something MAX-blah-blah? Totally unnecessary.

I worked it out with 10 positions.
I didn’t use any PWM pins as such, no libraries, or any of that - just a stock Arduino with 10 LEDs and 10 resistors.
I used a “lightbar” because it was handy, made for a small footprint. T1 LEDs could fit within the confines of a small protoboard or a “proto-shield”.

The Arduino paradigm focusses on digitalWrites, but that would have made for a lot of flicker. The key is “Port Manipulation”, poking (as we used to say in C64 BASIC) the PORTB and PORTD registers, getting the data out in parallel. Actually, there are two such operations: the PORTB chunk and the PORTD chunk.

I arranged an array of “frames” composed of 12 words each, bits 2 - 11 correspond to Digital pins.
In the following examples, “Frame 1” begins with the leading LED in bit 7 and in “Frame 2” it’s in bit 8.

//                             11
//                             1098765432    
const word dimbits[] = { 0b0000000011111100, // frame 1
//                             1098765432                                 
                         0b0000000111111000, // frame 2

Long story short: the brighter an LED is supposed to be, the greater the number of times it shows up in a frame’s words.

In the sketch (PDE attached), each word gets read and split into two bytes that are written to their respective port registers. The sketch grabs each line at machine speed, it strafes. The variable times_out sets the speed, it’s the number of times that all 12 lines in the “frame” get read and output (put out?).
In the demo, times_out = 7500 makes for a leisurely procession; 100 would make a solid bar while 100000 would be agonisingly slow.

Sorry if it’s a little blurry, but you should just get the idea, get it together and put it together, upload the sketch and enjoy.

[So, “noobs”, et al., grab the sketch and place it in a file with the same name (LarsonViaPortBD). ]

While tending to a request, I found a discontinuity in one of the dimbit words and corrected that in LarsonViaProtBD_b.pde

LarsonViaPortBD.pde (12.4 KB)

LarsonViaPortBD_b.pde (12.4 KB)

This is similar and has been "out there" for a long time now:

Mine doesn't require anything extra, a "proto-shield" would be nice, maybe, but a solderless breadboard will make it happen. My method of "PWM" is different and by composing a series of frames anyone should be able to come up with others patterns and effects fairly easily. And I've put it all out on the table, "how to do it" doesn't get more complete.

PWM can be done in software...! :)

Check out the SoftPWM library - not only will it allow you to PWM all the pins, but has built in support for fade up and fade down of values over time, which is exactly what you need for such an application

"SoftPWM library"... not required.

I came up with this because it's a n00b-faq.

Go with it or don't.

Hi "Dr Pancake"

Actually, it's Doctor Pancake, But anyway... (:

I have played around a little with direct port maniplulation and also Larson scanner code that I found using hardware PWM but found this restricting due to there only being six PWM pins on the Arduino Uno. I have also used the Blinkenlight code which I did manage to modify from his ten LED’s to the eight that I normally use for these types of code. would like to try your code but with only eight LED’s and I must admit that despite your thorough explanation I still do no quite get it. Would you mind showing me how to adapt it to using only eight LED’s and I will try and work out how it works. Thanks if you can help Pedro.

OK, I’m easy - see attached PDE.

I noticed a discontinuity (error) in one of the words in the dimbits array.
[Now, The Universe is back in balance and many lives have been spared.]

Its length is four segments, use digital outputs 2 - 9.

Larson_8_PortBD.pde (10 KB)

And, to shed more light on the subject, the attached sketch has two LEDs bouncing back and forth opposite each other, one is dim and one is bright, 8 positions/LEDs.

brtdimbounce.pde (9.59 KB)

I have one of these, works well, nice kit!

Thanks for that Runaway,

and glad to hear that you have restored cosmic harmony, may the force be with you 8) I can sleep easy tonight


Edit - just connected it up. Nice thank you.

Here are two more examples:

outward_8.pde has two leaders starting from the innermost and proceeding outward (no bounce)

static_fading_8.pde is just a strip of fading (frozen)

outward_8.pde (6.92 KB)

static_fading_8.pde (1.92 KB)

A clearer video of Larson Scanner, Anyone in action 8)

Here is my years Halloween project :) Cylonscanner with Runaway Pancakes code above... THANKS, it worked awesome and super easy to implement...

I Did it as a standalone board with just 10 LEDS, an ATMega328 and a Oscillator Resonator. Yeah I know I cheated and skipped the resistors... ]:) But it was perfect for fitting in a Jack-o-lantern... without getting pumpkin-goo on my Arduino board :)

The resistors were just a bridge too far then? [The old LEDs sans resistors jack-o'-lantern exigency. :grin: ]

"Happy Pancapkes"? Who's that? Like the man said about military fame, it's: "to be killed on the field of battle and have your name misspelled in the newspapers"

Happy Samhain, kids!

1 Like