Tag Archives: random numbers

Video: Electronic dice go random with AVR

A Maker named Walter recently created an entropy library for Atmel AVR microcontrollers (MCUs) to ensure a reliable source of truly arbitrary numbers.

As HackADay’s Brian Benchoff reports, the electronic dice generate random numbers by taking advantage of the watchdog timer’s natural jitter.

“[This isn’t] fast by any means but most sources of entropy aren’t that fast anyway,” Benchoff explains. “By sampling a whole lot of AVR chips and doing a few statistical tests, it turns out this library is actually a pretty good source of randomness, at least as good as a pair of dice.”

According to Benchoff, the circuit itself employs a pair of 8×8 LED matrices from Adafruit, an Atmel-based Arduino board and a pair of buttons.

Supported modes (11 total)?

  • 2d6
  • 2d4
  • 2d8
  • 2d10
  • 1d12
  • 1d20
  • Deck of cards
  • Single hex number
  • Single 8-bit binary number
  • 8 character alphanumeric password

Interested in learning more? You can watch the video above or check out the project’s official page here.

Generating random numbers with an ATtiny45

A HackADay forum member by the name of Karl wanted a hardware-based random number generator. His two primary criteria? Keeping costs low and ensuring sufficient generation of arbitrary numbers.

The solution? Atmel’s ATtiny45 microcontroller (MCU), paired with a USB/serial converter, three wires and a DIP socket.

“Some projects either require expensive parts (geiger tube), are quite big (lava lamp), or are not random enough. Also most of the projects require some soldering experience, which can be a problem for newbies,” Karl explained in a HackADay forum post.

“I was not happy with the options I found. Luckily I stumbled upon the Entropy library for AVR’s. I checked the results from authors’s web site. I also did a few tests on my own by creating a 1mb sample of random data. I was pleased with the quality of the random numbers.”

As HackADay’s Brian Benchoff explains, the AVRentropy uses the watchdog timer’s jitter in AVR microcontrollers to provide cryptographically secure random numbers.

“Setting up the circuit was easy – an ATtiny45 microcontroller was connected to an [inexpensive] USB to serial converter. Three wires, and the circuit is complete. The code was simple as well; it’s just a call to initialize the entropy and write the bits to the serial port,” Benchoff added.

“There are a few drawbacks to this build. Because the entropy library must wait until enough entropy is gathered, it can only produce about two 32-bit numbers per second. That’s all Karl needed for his application, though, and with an enclosure made from a wine cork and marble, he has the prettiest and smallest random number generator around.”

Interested in learning more about a hardware-based platform to generate numbers based with an ATtiny45? You can check out the original forum post here.