SOLVED - Pyboard lite does not generates random numbers

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
ovelap
Posts: 4
Joined: Thu Dec 15, 2016 12:22 pm

SOLVED - Pyboard lite does not generates random numbers

Post by ovelap » Fri Dec 16, 2016 10:05 am

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.
Last edited by ovelap on Fri Dec 16, 2016 9:02 pm, edited 4 times in total.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Pyboard generate random number

Post by pythoncoder » Fri Dec 16, 2016 11:18 am

Peter Hinch
Index to my micropython libraries.

ovelap
Posts: 4
Joined: Thu Dec 15, 2016 12:22 pm

Re: Pyboard generate random number

Post by ovelap » Fri Dec 16, 2016 1:14 pm

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).

shaoziyang
Posts: 363
Joined: Sun Apr 17, 2016 1:55 pm

Re: Pyboard generate random number

Post by shaoziyang » Fri Dec 16, 2016 2:08 pm

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).
not all pyboard support pyb.rng(), some device has not random number generator modual, such as STM32F401/F411.

ovelap
Posts: 4
Joined: Thu Dec 15, 2016 12:22 pm

SOLVED Re: Pyboard generate random number

Post by ovelap » Fri Dec 16, 2016 8:04 pm

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.

Post Reply