Hi Guys,  I am a noob here - and my coding skills are rusty. 

Hi Guys,
I am a noob here - and my coding skills are rusty.
I am trying to do something different with a 2812 strand.

I have seen the kitt and bounce lights, but I wonder if it would be possible to control stopping locations as well as direction more?

Think of it as a elevator going up and down - but random floors and direction.
I have searched around for a few days and have not found anything that gives these parameters…

Any thoughts much appreciated.

Working with Neopixel and an UNO.

Thanks,
Terkel

Hello Terkel. There probably isn’t anything like what you’re looking for, but that’s all possible. You need to define more precisely how it should work though to help figure out how to break it down and go about it.
Would the changing stopping position be randomly generated by MCU or based on some user input? Would it move continuously or only change periodically? Is only one end changing or both? Is it just a moving dot or a solid filed “bar”?

Hey Marc,
Thanks for replying.
I think the random stopping could just be randomized, but needs to have specific stopping points (an elevator doesn’t stop between floors). This could be an array of pre determined stopping points.
It would move, stop, pause for a bit, then move again. It could run on a cycle of a couple of minutes or I suspect infinite randomization might be simpler to build…
It would would be a bar of say 3-4 pixels.
I don’t understand your question of changing on one end or two…
I’m thinking, if it goes one way, stops, then it could randomly continue in sane direction or change to the opposite direction…

My question of “one end or both changing” was just wondering if one end of the pixels that light up was fixed or if it could move on either end of the pixels that were lit up. Sounds like you want it fixed on one end.

Here’s my thoughts of how I might go about it. First would be to decide how many sections you want to divide the strip up into. As an example, lets say it’s a 32 pixel strip and you want 8 sections (which would give 4 pixels/per section).

In the main loop you would periodically:

  • choose a new random stop point,
  • clear the strip,
  • figure out which pixels to light up,
  • then display it.

So this would become something like:

EVERY_N_SECONDS(120) { // run every 120 seconds
uint8_t pick = random8(1,9) // choose a new stop point
FastLED.clear(); // clear the strip

for (uint8_t i = 1; i <= (4*pick)-1; i++) {
leds[i] = CHSV(96,180,255); // assign a color
}

FastLED.show(); // display the pixels
}

Thank you Marc,
I’ll play with this a little later today.

Hi @Terkel_Sorensen ,
I found your idea of an elevator like sketch interesting. I saw Marc’s post and thought that it did not quite emulate an elevator and decided to write my own version of a very simple elevator simulation.
Here it is… http://pastebin.com/g1FdaQeX
Note that it works well enough here on my 8X8X8 RGB LED cube. Sorry it is the only hardware setup with RGB LEDs that I currently have available so note that you will have to modify that code to match your own LEDs array, pins etc…

Hi JP,

Thanks, it looks interesting.
I’m already running into a big issue… I managed to get myself some of the neipixel RGBW strips… Which apparently have less than optimal libraries.
It’ll work eventually

Ah yes, no FastLED library support for those yet. You might just have to hang on to those for the future and find something else for now. You’ll be future ready though! :slight_smile:

You will just need to put a bit more effort into adapting that code to work with the Adafruit library !
I assume Adafruit supports them RGBW !?!?

They say they do - but barely…
All their samples are doing really odd things, I did get some stuff running today. It’s strand naming that is off, anyway, I’ll try to pull this in with the neopixel library.

Btw, this is probably a dumb question - I did mention my coffee skills are rusty…

When I sent the code from Marc to the uno, I got a error "expecting a “’” or something… On this line
for(uint8_t i = 1; i <=(4*pick)-1; i++){

What did I mess up?

I forgot a semicolon on the end of this line:
uint8_t pick = random8(1,9)

Oops, I just realized that for loop won’t ever light up leds[0]. That’s what I get for trying to do something tricky to light up blocks of 4 pixels at a time. (The rest of it should work though.) I would probably still keep that for loop as is and just add an extra something somewhere to handle leds[0].

Thanks Marc,
I think I have a color code for the RGBW now, and it’s not one of the usual suspects - I’ll get it tested and will report back. Then I have to figure out if FastLED supports it.
And I will have to dig around and see if I have some old rgb strings I can test this on.

JP…
I have included both the neopixel and fastled libraries -
I get an error:
CRBG leds[NUM_LEDS]; does not name a type.
I checked the libraries and they appear ok.

Any thoughts?
I have strand test running with the rgbw now.

Btw, could not get it work on regular rgb stand. out of time for now, will continue later

@Terkel_Sorensen
Ok now I am confused…
First, can you explain why you want both Adafruit and FastLED libraries included !?
To my understanding FastLED does not support RGBW !
Then you say that you get errors but somehow have a RGBW strand test running and in the following post, that you could not get it to work on a regular RGB strand !?!?
Please post your code in either gist or pastebin and start a new support request. That will allow others that did not join this thread to see the problem and maybe provide help that I am not qualified enough to give.

@JP_Roy
Sorry, I think I got things confused there.
I was trying to get it up on the RGBW, b but that thing would barely run, so when I got going I was excited.
That said, I’m going for the RGB strand now, that should be simpler, although I still didn’t get it working.
I can’t tell you why I tonight both libraries was a good idea… Sometimes absence helps me see more clearly.
Sorry about the confusion.

@Terkel_Sorensen It is Ok do not worry, I want to help if you need it and know that you can find a solution.
If you are still stuck with a problem, it is best that you post your entire code and provide as much info as you can about your issue.
Best regards, JP

@JP_Roy
Ok, I have had a chance to work on the elevator - I thought it would work, but on a 30/m strip of neopixel (it’s what I had laying around), I could not get it to work.

I tested the strip with FastLED blink and Fire - works fine…
Would you take a look at the modified code?
http://pastebin.com/v3a7wX4U

Note, I removed the OCTOWS2811 library. It kept giving me errors and I think that one is specific to the Teensy?

See if what I have make sense.
Thanks.
Terkel