Truly Random Numbers

johnbbq

  • Full Member
  • ***
    • Posts: 30
    • View Profile
Has anyone figured how to create truly random numbers with the TinyArcade?

Per the tutorial (https://tinycircuits.com/blogs/learn/how-to-develop-a-game-for-the-tinyarcade-new), I checked the Arduino reference at https://www.arduino.cc/reference/en/language/functions/random-numbers/randomseed/

But pin 0 seems to be in use by the TinyArcade. The joystick does not work properly. I looked at the TinyArcade manual and it seems all pins are used. Or isn't it?

Any help will be really appreciated. Thanks!


thesko

  • Full Member
  • ***
    • Posts: 22
    • View Profile
I haven't deeply looked into it yet but will need that too...
My current approach is to use analogRead(0)+analogRead(1)+millis().

My only idea for now was to change millis() for micros(), but in my case I set the seed in setup().
And since it should take exactly the same amount of cycles each time I fear my random will not be very random :/

Cheers
the_sko


HunterHykes

  • Administrator
  • Full Member
  • *****
    • Posts: 20
    • View Profile
Hi John,

If you'd like to follow the guide on the link you posted, you're in luck because several pins on the Tiny Arcade are unused. The following are the unused pins on the main Tiny Arcade board: 1, 2, 8-12, 14-16, 29-32, 37, 38

I hope this helps. Let us know!

-Hunter


johnbbq

  • Full Member
  • ***
    • Posts: 30
    • View Profile
Fantastic Hunter, thank you! I used 8 and the seed worked great.

Cheers,


 

SMF spam blocked by CleanTalk