3v3.dev Log in / Sign up

· Funny ·

The Sympathy Die

Sheldon's idea, from our crazy-gadgets round: an electronic die that notices you have rolled badly three times running and, one time in three, quietly gives you a six. Rigged, but kind.

1. Make the board

Prompt

Make me an electronic die: seven red LED pips in the usual pattern, a ROLL button, a coin cell, and a small chip that can be programmed to be kind.

Why it is written this way

A die face only ever lights four groups of pips: the centre, one diagonal pair, the other diagonal pair and the middle pair. So the seven LEDs need just four pins of an ATtiny85, each LED with its own 220 Ω resistor, plus one pin for the ROLL button. The board is a white die face with the pips where a real die has them, a CR2032 on the back, a slide switch and a six-pin header to program it.

Output

create_project · add_component ×24 · assign_net_by_name · move_component · auto_route · add_zone · run_checks · share_board

No errors.

Front and back of a white board shaped like a die face. Front: seven small red LEDs in the pattern of a die, each with a resistor, and below them a ROLL button, an ATtiny85, a slide switch and a six-pin header. Back: the coin-cell holder over a ground pour.

2. The kindness

A fair die forgets. This one remembers your last three rolls, and if all three were a 1 or a 2, it gives you a six one time in three. Otherwise it is an ordinary die. The program has not been compiled or run on the board; the rule is all in one line, so make it as kind or as cruel as your family can bear. The pips go dark five seconds after each roll to save the coin cell, and the slide switch turns it fully off.

// The Sympathy Die (ATtiny85). An untested sketch.
// Pip groups: PB0 centre, PB1 one diagonal, PB2 the other diagonal, PB3 the middle pair. PB4 is the ROLL button.
const byte face[] = {0b0001, 0b0010, 0b0011, 0b0110, 0b0111, 0b1110};   // 1 to 6
int last[3] = {6, 6, 6};
unsigned long shown = 0;      // when the result went up; 0 = dark

void show(int n) { for (int b = 0; b < 4; b++) digitalWrite(b, (face[n - 1] >> b) & 1); }
void show0() { for (int b = 0; b < 4; b++) digitalWrite(b, LOW); }

void setup() {
  for (int b = 0; b < 4; b++) pinMode(b, OUTPUT);
  pinMode(4, INPUT_PULLUP);
}

void loop() {
  if (shown && millis() - shown > 5000) { show0(); shown = 0; }   // dark after five seconds
  if (digitalRead(4) == LOW) {
    randomSeed(micros());                       // how long you waited is the randomness
    for (int i = 0; i < 10; i++) { show(random(1, 7)); delay(40 + i * 15); }   // the tumble
    int roll = random(1, 7);
    bool unlucky = last[0] <= 2 && last[1] <= 2 && last[2] <= 2;           // three bad rolls running
    if (unlucky && random(3) == 0) roll = 6;    // one time in three, a quiet six
    last[0] = last[1]; last[1] = last[2]; last[2] = roll;
    show(roll);
    shown = millis();
    while (digitalRead(4) == LOW) {}
    delay(50);
  }
}

Do not use it for anything with money on the table.

3. In 3D

Prompt

Show me the front in 3D.

Why it is written this way

Seven pips, one button. Nothing on the front gives away that it cares.

Output

the 3D view

The front in 3D.

The white Sympathy Die board in 3D: seven red LED pips in a die pattern, the black ROLL button, the ATtiny85, the slide switch and the header.

Make it yourself

The board is open hardware under CERN-OHL-P: open it on 3v3.dev, copy it, change it, make it.

A QR code that opens this board's project page on 3v3.dev, where its Gerber files are.
Scan to open the project files on your phone.

The Gerber files are ready for any fab:

Gerber files (zip)

Your agent can build boards like this too. Connect it and start free: 20 boards a month, up to 4 layers, no card.

Try it free