Day 22

MakeCode Mystery Dreidel!

Dreidel is a traditional game played by families every year during the Jewish holiday of Hanukkah. In 2019, the first night of Hanukkah is Sunday, December 22 and the holiday continues for eight crazy nights.

A dreidel is a four-sided top with a Hebrew letter on each side, and the game is similar to dice. You spin the dreidel, and the letter on the side facing up tells you whether you get to take game pieces out of the pot, or have to put pieces in. The first person to get all the pieces wins!

You can play for any kind of small tokens, but at my house we always use chocolate gelt, or foil-wrapped coins. Mmm, chocolate....

The Hebrew letters on the side of the dreidel stand for Yiddish words that tell the player what to do. Here is what they look like and what they signify in the game:

The letter Nun stands for nisht or “nothing.” Player does nothing.

Gimel stands for gantz or “everything.” Player gets everything in the pot.

Hey means halb or “half.” Player gets half the pot (rounding up if there's an odd number).

Shin is for shtel ayn or “put in.” Player adds a game piece to the pot.

To add even more suspense, the sides on this Mystery Dreidel are unmarked, so you won't know what letters are spinning by.

That's where the programmable Adafruit Circuit Playground Express (CPX) comes in!

The CPX has a built-in tilt sensor (also called an accelerometer) that can sense which side is facing up when the dreidel stops spinning. For each of the four sides, you can write code to make different-colored lights shine through the hidden cut-out letters. Then you can program the CPX to play appropriate music to indicate whether the player has gain or lost points.

Programming is a snap using Microsoft MakeCode. MakeCode is a free online drag-and-drop programming language, very similar to MIT's Scratch.

In the sample MakeCode program above, I've labeled the side that goes with each stack of blocks. Above them is code that plays the traditional Dreidel song when you first turn on the CPX or when you turn it upside (as well as code that lets you switch off the sound if it gets annoying).

Bonus! The video below shows you how to insert the CPX into the cardboard dreidel and see more of how the sample code runs.