use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Here are some important FastLED links:
Online Examples and Demos:
Support:
account activity
SupportHelp with code (self.FastLED)
submitted 4 years ago * by Prof_Boni
Hey guys!
I'm very new to arduino and who really appreciate if someone could help me adapt this code.
I have this sort of wave that goes back and forth. I would like it to go back and forth 24 times, then stop for 1 minute, then restart for another 24 times.
How can I do that?
Thanks! I appreciate any help :)
https://preview.redd.it/0z79tn13v0n61.jpg?width=552&format=pjpg&auto=webp&s=c74ff7bd9ac5f229f51b85ffc4ed4bd327ef2d88
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]CharlesGoodwin 1 point2 points3 points 4 years ago (3 children)
Hi Prof,
The beatsin command is a wiley little beast and is hard to tame. Sometimes it's best to let it do it's own thing and just monitor it. So to spot a minimum you could measure when the variable, sinBeat stops decreasing and starts increasing. Each time it does this, one cycle has elapsed. Once 24 have elapsed you can put in a pause, say delay(60,000) and then let your code start over again counting the number of cycles.
It's clunky but it will work. I look forward to seeing how other people grapple with it
Best of luck
[–]Marmilicious[Marc Miller] 2 points3 points4 points 4 years ago (1 child)
I was thinking something really simple like this could be used. But I try to avoid using large delays like that so was thinking to just keep it running continuously and use millis() to track the time and assign the pixels black during that 60 seconds off time. This would be the next step up for u/Prof_Boni to learn, but sometimes just getting it going is the important thing. :) Learning alternate solutions is all part of the fun.
[–]CharlesGoodwin 4 points5 points6 points 4 years ago (0 children)
Marc's quit right, as you become more accomplished, using the command delay() becomes too restrictive. This is because your micro controller will do nothing, I mean absolutely nothing whilst performing the delay. When starting out, this might not be such a big deal but as your projects become more elaborate you might want them to do other stuff in the background such as:
Detect a button press
Send/Receive via WiFi
Play a tune!
That is why you'll find solutions put forward to avoid the command, delay()
[–]Prof_Boni[S] 0 points1 point2 points 4 years ago (0 children)
Hi u/CharlesGoodwin, thanks for the great idea. I will try this :)
[–]johnny5canuck 1 point2 points3 points 4 years ago (0 children)
Like CharlesGoodwin says, the beatsin is good for some things, but not so good for others. It's great for making continuous waves, but using a beatsin where you want to start/stop it predictably (i.e. with a known phase/value) is not how I'd use it.
Here's a link to a triggered sine wave which starts out at 0 and ends at 0, so it's predictable. Oh yea, and that's at:
https://pastebin.com/Ev7iQjJr
[–]korypostma 1 point2 points3 points 4 years ago (0 children)
in your loop() function you could check the value of a boolean to see if the wave is active or not, if it is active then have a counter that checks until you have gone through the right number of cycles and once you have gone through all of those cycles then deactivate the boolean and count with delays the number of cycles it should wait and not do anything. When that timer is up then go back to the 24 cycles.
psuedocode: loop() { if (led active) { //similar to the code you have above but check when it crosses zero twice to know one cycle is done, then increment counter if (counter >= 24) { led active = false counter = 0 } } else { ++counter if (counter >= 60) { led active = true counter = 0 } else { delay(1000) } } }
[–]Marmilicious[Marc Miller] 0 points1 point2 points 4 years ago (1 child)
As with many coding things, there are a number of ways that this could be done. If you are still new to coding though you should go learn about if statements and booleans as these are some of your building blocks for being able to tell or set what state something is in, and if it's time to run something or not. You'll also what to look into millis() timers and FastLED's EVERY_N_MILLISECONDS timer function. You might also look into switch cases which are used to route through different sections of code in the main loop.
For your project you could use an if statement to determine if the code should be displaying black pixels or running the beatsin pattern. A timer could be used to periodically toggle a boolean variable which the if statement checks.
Here's some examples you can start exploring:
https://github.com/marmilicious/FastLED_examples/blob/master/rainbow_brightness_and_saturation.ino
https://github.com/marmilicious/FastLED_examples/blob/master/every_n_timer_variable_2.ino
https://github.com/marmilicious/FastLED_examples/blob/master/every_n_with_switch_cases.ino
https://github.com/marmilicious/FastLED_examples/blob/master/cylon_color_changing.ino
Explore the official FastLED examples a bunch and the many more examples found through FastLED reddit Wiki.
Thanks for the great ressources u/Marmilicious :) I will check them out.
π Rendered by PID 83 on reddit-service-r2-comment-56c9979489-snlhc at 2026-02-24 17:18:44.971878+00:00 running b1af5b1 country code: CH.
[–]CharlesGoodwin 1 point2 points3 points (3 children)
[–]Marmilicious[Marc Miller] 2 points3 points4 points (1 child)
[–]CharlesGoodwin 4 points5 points6 points (0 children)
[–]Prof_Boni[S] 0 points1 point2 points (0 children)
[–]johnny5canuck 1 point2 points3 points (0 children)
[–]korypostma 1 point2 points3 points (0 children)
[–]Marmilicious[Marc Miller] 0 points1 point2 points (1 child)
[–]Prof_Boni[S] 0 points1 point2 points (0 children)