Skip to content

1KB Blackjack on a Custom ATtiny13 PCB

The assembled ATtiny13 blackjack handheld in its blue 3D-printed case, showing a hand on the OLED

The game uses two buttons:

  • Left button: hit (draw another card)
  • Right button: stand (the dealer plays out their hand)

After a round ends, pressing either button deals a new one. Your cards are at the bottom of the screen, the dealer’s are at the top, and the dealer’s first card stays face down (shown as ?) until you stand or bust. A smiley means you won and a frown means you lost.

The rules are simplified:

  • The dealer draws until reaching 17 or more
  • An ace counts as 11 whenever that doesn’t bust the hand
  • Each hand holds up to five cards
  • A tie counts as a win for the player

Limited (Bit-banged) I2C

A full I2C OLED driver would have taken up almost the entire flash memory, so I had to omit the bus-driver code, clock stretching, and any ACK or error checking.

Doubled Font and Minimal Character Support

A 5x8 font is doubled in size using a lookup table, so it renders as 12x16. Characters that are never used in the game are removed, leaving the final alphabet with just 20 letters, numbers, and symbols.

Pseudo-randomness

There is no hardware random number generator, so the seed comes from the lowest bit of eight readings of an unconnected analog pin. As that bit is mostly electrical noise, it serves as an okay seed.

Furthermore, predicting the next number is more difficult, since the random number generator is running constantly. Thus, the cards you get also depend on the timing of the player’s button presses.

For this project, I wanted the device to have a small form-factor, therefore, I designed a PCB in KiCad.

GitHub

Design files: