Main Content

Fortune Cookie Teller Hat

Long story: I originally made this hat for my company’s stall at Taipei International Book Exhibition, which was postponed from early February to May due to the threat of coronavirus (COVID-19). I thought it would be fun to wear a hat with bright texts (probably for ads or taglines) scrolling on it; You usually don’t see such things in a traditional book fair.

A few days ago, we learned that the book fair will still likely get canceled anyway.

Now, since the hat had lost its intended purpose, what should I do with it? How do I salvage this project?

In the end I decided to turned it into a wearable fortune (cookie) teller.

No need to eat a cookie, still get a fortune. And there are indeed people winning lottery because of fortune cookies. These fortunes might not be so useless as you think…right?

More specifically: when I pressed the button on the hat, the NodeMCU (ESP8266) microcontroller would query the free Fortune Cookie API and get a random result. It would also generate 6 random lottery numbers.

(No, we don’t have fortune cookies in Taiwan. And do you know fortune cookies are in fact invented by the Japanese?.)

The API requires you to use a “skip” parameter in order to get a specific fortune. However, MicroPython’s urandom module is not truly random - it always get the same sequence of numbers after reboot. So I had to update the NodeMCU’s system time via MicroPython’s ntptime module, and use the time as the randomize seed.

A small USB power bank hid inside the hat provides the power. A potentiometer can be used for adjusting brightness level of the MAX7219 modules.

My MAX7219 driver (included in the script) is based on Mcauser’s driver, which uses MicroPython’s built-in 8x8 characters of the framebuf module. However, since my LED modules are arranged in a different direction, I had to rotation all the stuff in the buffer 90 degrees counter-clockwise. This inevitably slows down the scrolling speed, but the texts are still readable.

The hat can be repurposed for other public uses in the future, as long as the API can be used on ESP8266. But I’m definitely not going to wear this thing on my way to work…”

Link to article

Related Content