Hi,
I want to blink with with one random LED from numbers od LEDs. LEDs are connected to pyboard. In micropython-lib there is dummy module random without funcionality. Exists another solution for it - generate random number in pyboard?
Thanks.
SOLVED - Pyboard lite does not generates random numbers
SOLVED - Pyboard lite does not generates random numbers
Last edited by ovelap on Fri Dec 16, 2016 9:02 pm, edited 4 times in total.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Pyboard generate random number
pyb.rng() is your friend: http://docs.micropython.org/en/latest/p ... y/pyb.html.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Pyboard generate random number
Thanks for your answer. But:
>>> import pyb
>>> pyb.rng()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'rng'
>>>
pyb.rng() is not accessible (last firmware 1.8.6).
>>> import pyb
>>> pyb.rng()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'rng'
>>>
pyb.rng() is not accessible (last firmware 1.8.6).
-
- Posts: 363
- Joined: Sun Apr 17, 2016 1:55 pm
Re: Pyboard generate random number
not all pyboard support pyb.rng(), some device has not random number generator modual, such as STM32F401/F411.ovelap wrote:Thanks for your answer. But:
>>> import pyb
>>> pyb.rng()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'rng'
>>>
pyb.rng() is not accessible (last firmware 1.8.6).
SOLVED Re: Pyboard generate random number
I have found this:
https://github.com/rguillon/micropython ... dom/random
I think that it generates "pseudo random" numbers (I am not math guy....). It is good solution for my project. LEDs looks like blinking randomously .
Thank to everybody who answered to my question.
https://github.com/rguillon/micropython ... dom/random
I think that it generates "pseudo random" numbers (I am not math guy....). It is good solution for my project. LEDs looks like blinking randomously .
Thank to everybody who answered to my question.