Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] How to call random functions in Arduino
(@jacchavez)
New Member
Joined: 9 years ago
Posts: 2
Topic starter
October 23, 2016 8:29 AM
Hello!
Thank you so much for your neat little page on LED effects! I might as well tell you my main goal on here. I would like to program the arduino to rotate a little servo motor that will be connected to a "disco ball" of LED's. I would like different effects to be called each time I turn on the arduino. (I will be attaching it to a 9V battery with a switch.) I have tried to use random numbers to call your functions, but I cannot get it to work. I have included the LED effects attachment as well as the servo attachment. I would like to know how I call a random function but also call the servo function no matter which LED function gets chosen.
(@jacchavez)
New Member
Joined: 9 years ago
Posts: 2
Topic starter
October 28, 2016 1:37 PM
Ok, I've got it.
Turns out I shouldn't code at 4 in the morning after a long hard day. I've come up with this code. The servo function is hard coded, but there's no shame in writing a function that works!
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2860
November 1, 2016 3:31 AM
Haha, coding at that time of day can have it's consequences hahah
Sorry for the late reply though - I am in the middle of moving from Europe to the US, and it's been quite busy, not to mention: all my stuff is in a huge container somewhere on the ocean haha.
Glad you figured it out though - and thanks for sharing the code.