Since you haven’t provided any code you have attempted, I like to generate a text based workflow to help understand what I think the code should look like. This gives me a game-plan to stick to. Usually I can predict errors here, in text, rather than in code, ahead of time (usually).
read button to see if it’s pressed
if pressed, generate a random number from 0 to NUM_LEDS, and make sure it’s not == LIT_LED_NUMBER
a) record the new LIT_LED_NUMBER
b) begin a one_minute_timer
-if one_minute_timer < 60 seconds, keep LED lit
-else, FADE_LED_OUT();
a)reset old LIT_LED_NUMBER flag so we can light it again
This sort stuff helps me a lot when tackling complex projects. SO, the next step would be to dissect the smaller parts of the code/hardware and try to get them to work.
Understand and build the test circuit on a breadboard with a button. There a TON of resources on Google, if you search Arduino Button. Shoot, even here you can search the community for keywords. Odds are, people have often run into similar problems and it has been discussed here.
If you don’t understand how data is stored and manipulated by the library, you’ll never learn to fly.
3)Understand how to keep time on the chip by using flags, timers, etc. Once again, get your fingers typing and learn the Google Foo!
If you are looking for help, often it’s best to share code you are working on. I have learned the most by this method from “upper echelon members” here
Yes it is possible to do what you are describing here. I do not believe that a single tutorial exists for it but…
Tutorials and example sketches do exist for the basic functionality that is required.
I would suggest you look into the ‘button’ example sketches that come with the Arduino IDE. It shows you how to use a pushbutton to light a simple LED. It is not much more complicated to turn on a specific LED within an adressable LED strip. Also look into the Arduino ‘debounce’ example sketch. You will definitely need something similar for your project. Next would be to play with the example sketches that come with the FastLED library and learn how to control individual LEDs within a strip. The FastLED library provides many example sketches from simple to complex.
It would be nice to know what you have managed to do so far with this. What microcontroller are you using or planning to use ? What LED type ? Any other special hardware ? etc… etc…
If you are already comfortable with pushbuttons and controlling an adressable LED strip using FastLED, upload your code to either pastebin or gist and it will be much easier to help you then.
This sounds exactly right.
I’d add that to accomplish the 2nd requirement “The button should be able to light other lights while the last ones remain on”, you could set up an array with NUM_LEDS to track which multiple lights are on, or even to track their current brightness.
Every X seconds, (look up the demo “Blink without delay” so that it can keep detecting button presses) you should loop through the array and reduce all the values’ brightness.
And each time you detect a button press, generate a random number up to NUM_LEDS, check if that particular light in the array is lit, and if so, pick randomly again (inelegant but fine for a short array where it won’t usually take so many tries to find an unlit light). If it’s not lit, set that value to be lit (eg 255 brightness).
That’s great advice thanks. I’m using a Teensy 3.1 with a ws2811 strip. I have wired the hardware and have the pushbutton test working so i guess i need to work from the ground up using the suggestions made here, Many thanks for the help in getting me started!
In my projects when i need buttons i use this library:
You can use click, double click, long click . Helpful to change pattern maybe using click, increse brightness with double click or decrease brightness with long click or wathever you need. The example in the library is very clear.
@Jonathan_Spring rather than tracking current brightness, do you think it would be better to track the length of time it has been on? This could allow me to do different things, like keep on for 60 seconds and then fade out.
@Rob_Hilken Yes is a great library. I found it last year and as i said before i use it a lot. You can use 2 buttons and if you add a couple of pot on analog pins you can change a lot of parameters while running your programs.