Arduino random numbers! - (Arduino Uno Programming for Beginners)

  Рет қаралды 961

Playduino

Playduino

Күн бұрын

Пікірлер: 13
@Volker-Dirr
@Volker-Dirr 8 ай бұрын
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.
@playduino
@playduino 8 ай бұрын
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-Dirr
@Volker-Dirr 8 ай бұрын
@@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.
@AlexanderWeurding
@AlexanderWeurding 8 ай бұрын
Love the share and reaction. Is there really something like a Random number;)
@playduino
@playduino 8 ай бұрын
Good question, I guess no, but by using all sorts of tricks we can get very close :)
@AlexanderWeurding
@AlexanderWeurding 8 ай бұрын
@@playduino verry close is the same as random. var word = translated, a new word, orfpan word etc
@SandhyaRani-i5y
@SandhyaRani-i5y 2 ай бұрын
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.
@playduino
@playduino 2 ай бұрын
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-i5y
@SandhyaRani-i5y 2 ай бұрын
@@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.
Why Random Numbers Aren't Random
9:17
Tech With Tim
Рет қаралды 77 М.
Un coup venu de l’espace 😂😂😂
00:19
Nicocapone
Рет қаралды 10 МЛН
Synyptas 4 | Жігіттер сынып қалды| 3 Bolim
19:27
kak budto
Рет қаралды 1,3 МЛН
How To Predict Random Numbers Generated By A Computer
13:54
PwnFunction
Рет қаралды 551 М.
My Secret: How I Became an Autonomous Robotics Engineer
8:06
ubicoders
Рет қаралды 16 М.
True Random Numbers - Computerphile
12:16
Computerphile
Рет қаралды 127 М.
DIY infrared transmitter (Arduino Uno Programming Basics)
17:51
Using random numbers with Arduino
13:02
Programming Electronics Academy
Рет қаралды 57 М.
Generate random numbers in Python 🎲
8:03
Bro Code
Рет қаралды 65 М.
Arduino MASTERCLASS | Full Programming Workshop in 90 Minutes!
1:25:31
Programming Electronics Academy
Рет қаралды 2,6 МЛН
Generating ACTUALLY Random Numbers in Python
7:26
NeuralNine
Рет қаралды 15 М.
Un coup venu de l’espace 😂😂😂
00:19
Nicocapone
Рет қаралды 10 МЛН