Using random numbers with Arduino

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ก.ย. 2024

ความคิดเห็น • 79

  • @programmingelectronics
    @programmingelectronics  3 ปีที่แล้ว +1

    ****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....

  • @walkswithmight9024
    @walkswithmight9024 4 ปีที่แล้ว +7

    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  4 ปีที่แล้ว

      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 2 ปีที่แล้ว

      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 !!!!

  • @davisactual
    @davisactual 2 ปีที่แล้ว +1

    thorough but not verbose.. very good quality and the editing is def worth the time as it greatly helps the experience of the viewer!

  • @thedownhilla
    @thedownhilla หลายเดือนก่อน +1

    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!

  • @gordonyoud5975
    @gordonyoud5975 7 ปีที่แล้ว +1

    So very clean concise tutorial on random number generation, thank you.

  • @joshuapitong899
    @joshuapitong899 2 ปีที่แล้ว +1

    Great help.🙌 Thank you.😊

  • @thevastenigma2464
    @thevastenigma2464 2 ปีที่แล้ว +1

    Great video, you are awesome!

  • @MrBanzoid
    @MrBanzoid 3 ปีที่แล้ว +1

    Most interesting, thanks.

  • @MrOrnidoko
    @MrOrnidoko 4 ปีที่แล้ว +1

    awesome, i used half of your code to fix my issue! thanks alot

  • @AioTranNhan
    @AioTranNhan 8 ปีที่แล้ว

    thank you very much, my instructor asked us to do something like this without teaching and I was kinda overwhelming. thanks this help alot

  • @شيماءالملاح-ع3ب
    @شيماءالملاح-ع3ب 3 ปีที่แล้ว +1

    Thanks!

  • @kingshahzad78
    @kingshahzad78 5 ปีที่แล้ว +1

    nice explanation sir. Excellent presentation

  • @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.

  • @armaansharma1080
    @armaansharma1080 3 ปีที่แล้ว +1

    Thanks man!

    • @programmingelectronics
      @programmingelectronics  3 ปีที่แล้ว

      Glad it was helpful! Are there any specific Arduino topics you would like covered?

  • @arachnophillic9709
    @arachnophillic9709 8 ปีที่แล้ว +3

    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.

  • @ANAZ-RX7
    @ANAZ-RX7 ปีที่แล้ว +1

    bro i love you and your way of explaining and teaching things, really you're the best.... with all my thanks to you❤❤

  • @nyakoi
    @nyakoi 4 ปีที่แล้ว

    Thank you!

  • @abishekjabez9853
    @abishekjabez9853 2 ปีที่แล้ว +1

    7:25 '42' i see what you did there (Hitch hikers guide to the galaxy)

    • @Artichoked1
      @Artichoked1 2 ปีที่แล้ว

      Ayyy I saw that too!

  • @jamesb.8393
    @jamesb.8393 2 ปีที่แล้ว +1

    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?

  • @Ctairs
    @Ctairs 3 ปีที่แล้ว +1

    how can i make it so that it only generates a number once?

  • @maurelius6463
    @maurelius6463 8 ปีที่แล้ว +4

    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

  • @willemnorval876
    @willemnorval876 8 ปีที่แล้ว +1

    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 ?

  • @hj0835
    @hj0835 7 ปีที่แล้ว +2

    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  7 ปีที่แล้ว +1

      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 7 ปีที่แล้ว +2

      Makes more than sense, thank you.

  • @meande-man5351
    @meande-man5351 6 ปีที่แล้ว

    Thats awesome! gotta love random

  • @pokednaful
    @pokednaful 2 ปีที่แล้ว +1

    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;
      }

  • @TomDcanada
    @TomDcanada 3 ปีที่แล้ว

    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 .

  • @tarikbenghannou9028
    @tarikbenghannou9028 4 ปีที่แล้ว

    hi i need to give the value of number random to servomotor
    please help me to found a solution
    thank you

  • @GTX4747
    @GTX4747 8 ปีที่แล้ว +1

    awesome!

  • @mohamadrafeekmaatouki3888
    @mohamadrafeekmaatouki3888 3 ปีที่แล้ว

    It helps me realy

  • @gregenxelcreates
    @gregenxelcreates 5 ปีที่แล้ว

    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?

  • @jaredcohen9552
    @jaredcohen9552 6 ปีที่แล้ว

    what happens if you use all of the analog pins? how would you use the random seed?

  • @taranagnew436
    @taranagnew436 5 ปีที่แล้ว

    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 ปีที่แล้ว +1

    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 6 ปีที่แล้ว

      can you please post a link to the video, thank you

  • @ArduinoAzerbaycan
    @ArduinoAzerbaycan 7 ปีที่แล้ว

    Super!!!!!!!!!!!!!

  • @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 ปีที่แล้ว +1

      +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 ปีที่แล้ว +1

      Open Source Hardware Group That's smart! Thanks :D

    • @programmingelectronics
      @programmingelectronics  9 ปีที่แล้ว

      I hope it works ok - best of luck!

  • @rolandvarga5179
    @rolandvarga5179 3 ปีที่แล้ว

    10:37

  • @nathanielcorey6747
    @nathanielcorey6747 6 ปีที่แล้ว

    42 lol I see you have read that book

  • @MrEuphonious
    @MrEuphonious 2 ปีที่แล้ว +1

    Thanks so much.
    I was getting all kinds of headaches with generating random numbers

  • @alienc5920
    @alienc5920 4 ปีที่แล้ว +4

    The best explanation and ilustration of all. TH-camrs should learn fron this tutorial. Clear, professional and to the ponit without annoying background music. THANK YOU!!

  • @jameshenry8015
    @jameshenry8015 5 ปีที่แล้ว +2

    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 ปีที่แล้ว +1

    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 8 ปีที่แล้ว +2

    Fantastic tutorial. Learned so much in a short space of time

    • @programmingelectronics
      @programmingelectronics  8 ปีที่แล้ว +1

      +ArcanePath360 Awesome to hear! Thanks a ton for watching, I hope you find the other lessons helpful too.

  • @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

  • @tomguenthner2493
    @tomguenthner2493 5 ปีที่แล้ว

    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.

  • @lutfilawijaya6588
    @lutfilawijaya6588 4 ปีที่แล้ว +1

    Those randomSeed tutorials help me a lot, thanks !

  • @ferryvandergaag304
    @ferryvandergaag304 6 ปีที่แล้ว +1

    Je hebt echt skire lampjes

  • @arjayballester520
    @arjayballester520 5 ปีที่แล้ว

    Hello i'm already using the random seed, and it seems that no changes at all. will you help me ? thanks a lot

  • @kartitamohsine8016
    @kartitamohsine8016 4 ปีที่แล้ว

    thank you,please i want to ask you how to turn led on after a random of time

  • @sagittariusblackerz4391
    @sagittariusblackerz4391 8 ปีที่แล้ว

    amazing men, please how can i to do time random ? i cant finding this information helpme what s millis ? thanks

  • @foxtrot151000
    @foxtrot151000 6 ปีที่แล้ว

    Anyone know of this could work on an Attiny85?