Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Help! Can the microcontroller randomize?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Help! Can the microcontroller randomize?

by JennaF on Sun Nov 24, 2019 10:43 pm

I am new to the site and would like some help with a problem. I am trying to animate my Circuit Playground Express controller to make a lucky wheel spinning animation to have the white photon land on a random number. In Adafruit, the animation shows a random result every time, even when I reset. But when I upload the file to my controller and reset, it always plays in the exact same sequence.

Why can't the controller actually randomize like it is programmed to? I am attaching a screenshot of my code, please tell me if there are issues with it that I am not seeing. I am trying to make a little game for my students, but this constant sequence is not random or fair.

Screen Shot 2019-11-24 at 9.23.59 PM.png
Screen Shot 2019-11-24 at 9.23.59 PM.png (167.88 KiB) Viewed 190 times


Is there a way to solve this? Please help me out, I am very frustrated!

JennaF
 
Posts: 1
Joined: Sun Nov 24, 2019 10:31 pm

Re: Help! Can the microcontroller randomize?

by nickine9 on Mon Nov 25, 2019 4:53 am

I think the Random function is not really random. some languages have a function to "seed" the random function to generate a new pseudo random sequence but i don't think that is implemented in make code. You might be able to do something in javascript under the covers.

nickine9
 
Posts: 141
Joined: Fri Jan 06, 2017 4:14 am

Re: Help! Can the microcontroller randomize?

by johnpark on Tue Nov 26, 2019 12:19 pm

I just tried a simplified version of this and it seems to work well on the Circuit Playground Express hardware. https://makecode.com/_EbUFAYha0UyH

johnpark
 
Posts: 767
Joined: Wed Mar 25, 2009 2:15 pm

Re: Help! Can the microcontroller randomize?

by johnpark on Mon Dec 02, 2019 2:03 pm

You can use randomization in many ways, such as to produce varying LED colors, sounds, even different values for a guessing game.

johnpark
 
Posts: 767
Joined: Wed Mar 25, 2009 2:15 pm

Please be positive and constructive with your questions and comments.