Using random numbers with Arduino

  Рет қаралды 58,518

Programming Electronics Academy

Programming Electronics Academy

Күн бұрын

Пікірлер: 84
@programmingelectronics
@programmingelectronics 4 жыл бұрын
****If you like this, I think you'll like the premium Arduino training we offer. You can check it out here**** bit.ly/3lHyzcB
@heebakl
@heebakl 2 жыл бұрын
I was wondering if the premium course accepts debit card payments or do I have to stick with credit card payment....
@alienc5920
@alienc5920 4 жыл бұрын
The best explanation and ilustration of all. KZbinrs should learn fron this tutorial. Clear, professional and to the ponit without annoying background music. THANK YOU!!
@Artichoked1
@Artichoked1 2 жыл бұрын
*point
@walkswithmight9024
@walkswithmight9024 5 жыл бұрын
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!
@programmingelectronics
@programmingelectronics 5 жыл бұрын
So great to hear it helped! Thanks for watching!
@richierich3135
@richierich3135 4 жыл бұрын
SAME THING HAPPENED TO ME , THIS TUTORIAL SAVED ME , THANKS ALOT SIR.
@jimbarrett2152
@jimbarrett2152 3 жыл бұрын
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 !!!!
@lutfilawijaya6588
@lutfilawijaya6588 4 жыл бұрын
Those randomSeed tutorials help me a lot, thanks !
@programmingelectronics
@programmingelectronics 4 жыл бұрын
Glad you like them!
@davisactual
@davisactual 3 жыл бұрын
thorough but not verbose.. very good quality and the editing is def worth the time as it greatly helps the experience of the viewer!
@programmingelectronics
@programmingelectronics 3 жыл бұрын
Much appreciated! Thanks for the kind words!
@gordonyoud5975
@gordonyoud5975 7 жыл бұрын
So very clean concise tutorial on random number generation, thank you.
@ANAZ-RX7
@ANAZ-RX7 Жыл бұрын
bro i love you and your way of explaining and teaching things, really you're the best.... with all my thanks to you❤❤
@programmingelectronics
@programmingelectronics Жыл бұрын
Thank you so much Anas 😀!
@thedownhilla
@thedownhilla 5 ай бұрын
Really helpful stuff! I like how you evolved the code step by step, with explanations en-route : )) I'm just starting with Arduino, aiming to light sci-fi model kits!
@programmingelectronics
@programmingelectronics 5 ай бұрын
Glad it was helpful!
@jameshenry8015
@jameshenry8015 5 жыл бұрын
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!
@christmasdreams1
@christmasdreams1 10 жыл бұрын
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!
@programmingelectronics
@programmingelectronics 10 жыл бұрын
Derrick Windsor Great point about maintaining attention - I had not thought about it from that angle.
@ArcanePath360
@ArcanePath360 9 жыл бұрын
Fantastic tutorial. Learned so much in a short space of time
@programmingelectronics
@programmingelectronics 9 жыл бұрын
+ArcanePath360 Awesome to hear! Thanks a ton for watching, I hope you find the other lessons helpful too.
@abishekjabez9853
@abishekjabez9853 3 жыл бұрын
7:25 '42' i see what you did there (Hitch hikers guide to the galaxy)
@Artichoked1
@Artichoked1 2 жыл бұрын
Ayyy I saw that too!
@MrEuphonious
@MrEuphonious 2 жыл бұрын
Thanks so much. I was getting all kinds of headaches with generating random numbers
@programmingelectronics
@programmingelectronics 2 жыл бұрын
So glad it helped Njei!!
@joshuapitong899
@joshuapitong899 2 жыл бұрын
Great help.🙌 Thank you.😊
@programmingelectronics
@programmingelectronics 2 жыл бұрын
Glad it helped! Thanks Joshua!!
@Cr3cked
@Cr3cked 21 күн бұрын
THANK YOU! I Was Making A Game And Needed Buttons, But I Suck With Resistors. After Following YOUR Tutorial, I Made It! Thanks!
@programmingelectronics
@programmingelectronics 19 күн бұрын
Glad it helped with your game!
@thevastenigma2464
@thevastenigma2464 3 жыл бұрын
Great video, you are awesome!
@programmingelectronics
@programmingelectronics 3 жыл бұрын
Thanks a ton!
@MrOrnidoko
@MrOrnidoko 5 жыл бұрын
awesome, i used half of your code to fix my issue! thanks alot
@programmingelectronics
@programmingelectronics 5 жыл бұрын
Great - glad it helped some!
@MrBanzoid
@MrBanzoid 4 жыл бұрын
Most interesting, thanks.
@kingshahzad78
@kingshahzad78 5 жыл бұрын
nice explanation sir. Excellent presentation
@programmingelectronics
@programmingelectronics 5 жыл бұрын
Thanks Khurram!
@jamesb.8393
@jamesb.8393 3 жыл бұрын
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?
@AioTranNhan
@AioTranNhan 9 жыл бұрын
thank you very much, my instructor asked us to do something like this without teaching and I was kinda overwhelming. thanks this help alot
@maurelius6463
@maurelius6463 8 жыл бұрын
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!
@christopherchance4860
@christopherchance4860 6 жыл бұрын
look into neo-pixels Adafruit has example code that will do that very thing
@arachnophillic9709
@arachnophillic9709 8 жыл бұрын
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.
@Ctairs
@Ctairs 3 жыл бұрын
how can i make it so that it only generates a number once?
@TomDcanada
@TomDcanada 4 жыл бұрын
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 .
@شيماءالملاح-ع3ب
@شيماءالملاح-ع3ب 3 жыл бұрын
Thanks!
@willemnorval876
@willemnorval876 8 жыл бұрын
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 ?
@armaansharma1080
@armaansharma1080 3 жыл бұрын
Thanks man!
@programmingelectronics
@programmingelectronics 3 жыл бұрын
Glad it was helpful! Are there any specific Arduino topics you would like covered?
@meande-man5351
@meande-man5351 6 жыл бұрын
Thats awesome! gotta love random
@candrasniper3404
@candrasniper3404 3 жыл бұрын
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.
@nyakoi
@nyakoi 4 жыл бұрын
Thank you!
@kartitamohsine8016
@kartitamohsine8016 5 жыл бұрын
thank you,please i want to ask you how to turn led on after a random of time
@taranagnew436
@taranagnew436 6 жыл бұрын
can you plz tell me where to get or what to type to get the labels you are using on your uno?
@DaRKeTaMiN
@DaRKeTaMiN 9 жыл бұрын
Is there anyway to stop it repeating the same number twice in a row?
@programmingelectronics
@programmingelectronics 9 жыл бұрын
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!
@programmingelectronics
@programmingelectronics 9 жыл бұрын
Just made a video answering this question Chris Punton . It will air on July 14th. Thanks for asking it!
@taranagnew436
@taranagnew436 7 жыл бұрын
can you please post a link to the video, thank you
@hj0835
@hj0835 8 жыл бұрын
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.
@programmingelectronics
@programmingelectronics 8 жыл бұрын
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.
@hj0835
@hj0835 8 жыл бұрын
Makes more than sense, thank you.
@GTX4747
@GTX4747 8 жыл бұрын
awesome!
@tomguenthner2493
@tomguenthner2493 6 жыл бұрын
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.
@jaredcohen9552
@jaredcohen9552 7 жыл бұрын
what happens if you use all of the analog pins? how would you use the random seed?
@tarikbenghannou9028
@tarikbenghannou9028 4 жыл бұрын
hi i need to give the value of number random to servomotor please help me to found a solution thank you
@goldstandard7406
@goldstandard7406 4 жыл бұрын
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
@gregenxelcreates
@gregenxelcreates 6 жыл бұрын
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?
@arjayballester520
@arjayballester520 6 жыл бұрын
Hello i'm already using the random seed, and it seems that no changes at all. will you help me ? thanks a lot
@Cr3cked
@Cr3cked 26 күн бұрын
Can someone pls help me understand serial?
@programmingelectronics
@programmingelectronics 25 күн бұрын
Maybe this can help? www.programmingelectronics.com/serial-communication/ All the best!
@Cr3cked
@Cr3cked 24 күн бұрын
@@programmingelectronics Thanks!
@pokednaful
@pokednaful 2 жыл бұрын
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
@programmingelectronics
@programmingelectronics 2 жыл бұрын
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; }
@sagittariusblackerz4391
@sagittariusblackerz4391 8 жыл бұрын
amazing men, please how can i to do time random ? i cant finding this information helpme what s millis ? thanks
@mohamadrafeekmaatouki3888
@mohamadrafeekmaatouki3888 4 жыл бұрын
It helps me realy
@TheMusterionOfRock
@TheMusterionOfRock 9 жыл бұрын
What if I need to use all 20 pins on the arduino, how would you generate a non repeating random number?
@programmingelectronics
@programmingelectronics 9 жыл бұрын
+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.
@TheMusterionOfRock
@TheMusterionOfRock 9 жыл бұрын
Open Source Hardware Group That's smart! Thanks :D
@programmingelectronics
@programmingelectronics 9 жыл бұрын
I hope it works ok - best of luck!
@TexnoBey
@TexnoBey 8 жыл бұрын
Super!!!!!!!!!!!!!
@foxtrot151000
@foxtrot151000 7 жыл бұрын
Anyone know of this could work on an Attiny85?
@rolandvarga5179
@rolandvarga5179 3 жыл бұрын
10:37
@ferryvandergaag304
@ferryvandergaag304 7 жыл бұрын
Je hebt echt skire lampjes
@realteigertjuh
@realteigertjuh 7 жыл бұрын
HAHAHAHAHHAHAHAHHAHAHHAHA
@nathanielcorey6747
@nathanielcorey6747 7 жыл бұрын
42 lol I see you have read that book
Arduino for kids: Random Blinking LEDs
12:58
learnelectronics
Рет қаралды 6 М.
Arduino MASTERCLASS | How to Use Control Structures PART 6
21:39
Programming Electronics Academy
Рет қаралды 37 М.
БАБУШКА ШАРИТ #shorts
0:16
Паша Осадчий
Рет қаралды 4,1 МЛН
3 Ways to Use Acceleration in an Arduino Sketch
17:37
Programming Electronics Academy
Рет қаралды 40 М.
Arduino Pseudo Random Non-Consecutive Number Generator
11:13
Programming Electronics Academy
Рет қаралды 15 М.
How to Use a Button with an Arduino (Lesson #5)
20:57
Science Buddies
Рет қаралды 114 М.
How to do multiple tasks in Arduino | Beginners | millis() function
10:23
Timer Interrupt ISR + Examples | Arduino101 | Set Registers & Modes
16:13
How to use millis() function to multitask in arduino code.
10:34
Mario's Ideas
Рет қаралды 64 М.
Create an Arduino Library (Step by Step)
19:41
Robotics Back-End
Рет қаралды 48 М.