Nice video. Just some additional information: - Setting the random seed only once at the beginning is sometimes very useful, since it is easier to debug your code. - Using millis() as seed is not good if you need very many random times, since if millis() didn't change (since the Arduino is fast), you always get the same random number - If you need very many random numbers it is better to not always reset the seed, since that is slow. - Don't use milllis() if you want to code security based code like generating random numbers for encrypted communication. Because for skilled coders this will be too less random. But for "normal" use case millis() is fine. - very good that you noticed that analogRead is only 10 bits, but the seed should have more bits. I didn't thought fully about bugs, but i think a variant like randomSeed(analogRead(0)+analogRead(1)*64+analogRead(2)*4096+...) might be fine. A nice task is always writing a small dice checker. So for example throwing the dice 60000 and count how many times you get the 1, 2, 3, 4, 5 and 6. And then check if each number is around 10000 shown. Because with such an easy test you might already find bugs like setting the seed too fast and/or wrong/bad random() functions. I remember in the past guys coded the random() function by using a function that returns a float with values between 0 and 1. And while converting that float into an integer they done it wrong and by that the number 1 showed on the dice only 5000 times (instead of 10000) and the number 6 showed 15000 times (instead of 10000), because they rounded wrong.
@playduino8 ай бұрын
Thank you very much for the valuable additional information! The dice checker is a great idea, I will definitely do this at the end of the project
@Volker-Dirr8 ай бұрын
@@playduino It just flashed my mind: Maybe also write a similar check for "analogRead(0)". So see how random that is. So reading it maybe 1024000 times and see how many times each number is read. I am not sure, but i guess/fear that the analogRead might not always change if you read too fast, so also with a small delay it might be better.
@AlexanderWeurding8 ай бұрын
Love the share and reaction. Is there really something like a Random number;)
@playduino8 ай бұрын
Good question, I guess no, but by using all sorts of tricks we can get very close :)
@AlexanderWeurding8 ай бұрын
@@playduino verry close is the same as random. var word = translated, a new word, orfpan word etc
@SandhyaRani-i5y2 ай бұрын
Nice explanation thank you so much. i am following all your videos, can you please make a video on timer interrupts how they work, how to set time by using timer 0.
@playduino2 ай бұрын
Thank you, i touch the topic a little bit in this video: kzbin.info/www/bejne/Z2GpnIiKZrdpmbMsi=iyxeVv8mz75GZOnf (By using a library for timer1)
@SandhyaRani-i5y2 ай бұрын
@@playduino Thank you so much for replying i have seen the video. it was very effective. but my doubts was not cleared. can you please help me, I'm fresher i am not aware of Arduino Uno after watching your videos i got many things, If you don't mind can you please explain me the datasheet of atmega328p timer0 8 bit register, i feel very glad if you help me. thank you so much once again. please help me in understanding datasheet.