Using random numbers with Arduino
Vložit
- čas přidán 11. 06. 2024
- 🤩 FREE Arduino Crash Course 👇👇
bit.ly/get_Arduino_skills
**If you like this, I think you'll like the premium Arduino training we offer. Check it out here** bit.ly/3nSBPUs
This video tutorial walks through the use of the random() and randomSeed() function as it pertains to Arduino. We first investigate the output of the random function, why we need to use the randomSeed function to generate more apparent randomness and how to do it. We then use the randomly generated numbers to turn on and off three separate LEDs...randomly...
****If you like this, I think you'll like the premium Arduino training we offer. You can check it out here**** bit.ly/3lHyzcB
I was wondering if the premium course accepts debit card payments or do I have to stick with credit card payment....
The best explanation and ilustration of all. CZcamsrs should learn fron this tutorial. Clear, professional and to the ponit without annoying background music. THANK YOU!!
*point
I must have spent 4 hours last night searching for the answer this and proper examples and instruction to figure this out, and you sir, are a genius! THANK YOU!
So great to hear it helped! Thanks for watching!
SAME THING HAPPENED TO ME , THIS TUTORIAL SAVED ME , THANKS ALOT SIR.
Yes ! This tutorial certainly explains clearly a very useful and fascinating function that you can use / I wonder if it can be used as an ‘interrupt’? I will try. My interest is in LED Cubes / one led color or the RGB LED / just plain fascinating !!!!
Thanks so much.
I was getting all kinds of headaches with generating random numbers
So glad it helped Njei!!
So very clean concise tutorial on random number generation, thank you.
Those randomSeed tutorials help me a lot, thanks !
Glad you like them!
I did the same sort of thing on a Mega 2560 with 26 white LEDs in a row. I refined it to a short delay (10) with an analogRead random seed and the effect is somewhat mesmerizing. I call it Rain Dance because it reminds me of a rain storm hitting lit pavement at night. It runs 24/7 in my office and has been since December 23!
bro i love you and your way of explaining and teaching things, really you're the best.... with all my thanks to you❤❤
Thank you so much Anas 😀!
thorough but not verbose.. very good quality and the editing is def worth the time as it greatly helps the experience of the viewer!
Much appreciated! Thanks for the kind words!
Fantastic tutorial. Learned so much in a short space of time
+ArcanePath360 Awesome to hear! Thanks a ton for watching, I hope you find the other lessons helpful too.
thank you very much, my instructor asked us to do something like this without teaching and I was kinda overwhelming. thanks this help alot
Another terrific tut ! Random, I like ! Any regularity causes the brain's "Flight or Fight" response, which is strictly attuned only to "new events", to wander away once it has determined that no threat exists. Therefore, Random Events are better for holding viewers attention, (to a degree, of course, because blinking lights as a rule are not a 'danger' per se! ). keep up the great work!
Derrick Windsor Great point about maintaining attention - I had not thought about it from that angle.
awesome, i used half of your code to fix my issue! thanks alot
Great - glad it helped some!
Great help.🙌 Thank you.😊
Glad it helped! Thanks Joshua!!
Thanks for your classes! How can I combine this random blink sketch with a led fade sketch? I'm trying to have five LEDs fade in and out in a random pattern with overlapping phases. Kind of like a slow ebb and flow effect. Any tips? Keep up the great work!
look into neo-pixels
Adafruit has example code that will do that very thing
Your tutorial on the ‘random’ function and the ‘random seed’ function was excellent/ I would like to apply this bit of info to an 8x8x8 LED Cube / if I increased the number of Leds’ to 512 and sent out the A0 to 8 shift registers and at the same time to a layer ( 1 thru 8 ) ...........could that produce a random light in the cube at a specified delay . And yes , there is definitely one way to find out :-). Your thoughts?
Most interesting, thanks.
Thats awesome! gotta love random
These tutorials are great . Could your delay be replaced with millis ? I have looked at your millis tutorials but can’t make the jump to replacing the delay in this tutorial . Any help would be appreciated .
Great video, you are awesome!
Thanks a ton!
i used random number generators in my 6x6x6 rgb led cub to make color changing rain that starts at a random led each time with a random color.
nice explanation sir. Excellent presentation
Thanks Khurram!
thank you,please i want to ask you how to turn led on after a random of time
Thanks!
Thank you!
what happens if you use all of the analog pins? how would you use the random seed?
I want to use a 4 or 5 digit random access number for each guest at a hotel. These numbers should be 'recognised' by Arduino and transcribed back to the one code that is actually the only true access code to allow access. How can that be done ?
I just followed this tutorial and my LED's are all blinking at the same time. They are doing the exact same thing. What could be the issue?
Hello i'm already using the random seed, and it seems that no changes at all. will you help me ? thanks a lot
can you plz tell me where to get or what to type to get the labels you are using on your uno?
Question. I have been trying to figure this out for a little while now. I want some leds to blink random for a delay controlled by a pot. My lights flash correctly for one sequence. Takes about 1.5 seconds. If the delay is 10 seconds, the last 8.5 stay solid on the last random color. I don't want to use mills because the arduino will have power for long periods of time. But the lights come on from a sensor input. Any help would be cool. Thanks for your time. I remember seeing a solution to this problem in one of your earlier tutorials. If you could just point me there I would be grateful
amazing men, please how can i to do time random ? i cant finding this information helpme what s millis ? thanks
How to catch random number to a variable in void loop that will not change before the syntax has finished, so we can call it. Example, I press the button, and random number is generated, we catch it to a variable, then I press the keypad to fulfill a number, then I press another button to compare my input number to the variable than contains the random number before.
how can i make it so that it only generates a number once?
awesome!
hi i need to give the value of number random to servomotor
please help me to found a solution
thank you
Once I get a random number I want to use it for display it . I only need one random number. How do I just get the one number? Thanks.
This works great, I increased it to 10 leds, which each led is in a model hotel room....Now how would I go about telling it to use random time also? If you could give me an idea where to start. Thanks and Thanks for all the other vid's you have done. I have learned alot from them.
Hi Jim - great question. Depending on how you have blinked your LED (I am assuming you are employing the delay function?), you could try using the random number generated to be the value used by delay().
i.e....
...turn LED ON...then...
myRandomNumber = random(100, 1000);
delay(myRandomNumber);
...turn LED OFF...then...
//another randomly timed delay
Does this make sense? Have a good one.
Makes more than sense, thank you.
Thanks man!
Glad it was helpful! Are there any specific Arduino topics you would like covered?
It helps me realy
Anyone know of this could work on an Attiny85?
How to get highest number jn arduino?
Example i get 2 sensor. Sensor 1 detected 100, and sensor 2 detected 80
I want to take the i highest number automaticly
In code, you could have an if statement that compares the two values.. something like...
If(sensor_2 > sensor_1){
highestReading = sensor_2;
} else {
highestReading = sensor_1;
}
Super!!!!!!!!!!!!!
7:25 '42' i see what you did there (Hitch hikers guide to the galaxy)
Ayyy I saw that too!
Is there anyway to stop it repeating the same number twice in a row?
Chris Punton Great question! My first though would be to start looking around for some type of random number generator library that would give you more options other than the built in random function.
But if that turned up nothing, you might be able to store the previous random generated value in a variable, and then compare it to the next value generated by the random function. If they match, than have if statement generate another random variable.
Hope this helps some. Have a good one!
Just made a video answering this question Chris Punton . It will air on July 14th. Thanks for asking it!
can you please post a link to the video, thank you
What if I need to use all 20 pins on the arduino, how would you generate a non repeating random number?
+The Musterion Of Rock, You could use the output of the millis() function to generate a random seed every time through the loop. This might do the trick.
Open Source Hardware Group That's smart! Thanks :D
I hope it works ok - best of luck!
10:37
Je hebt echt skire lampjes
HAHAHAHAHHAHAHAHHAHAHHAHA
42 lol I see you have read that book