Electronic dice application for the mBuino platform. Notes: The mBuino starts in Demo mode. In Demo mode the LEDs are lighted, showing sweeps and demo rolls. Connect a button or tilt-switch between P0.4 and GND. No soldering required! When the switch is triggered mBuino goes into Roll mode. In Roll mode mBuino starts with rapid flickering LEDs. Each subsequent switch trigger will perform a roll of the dice, of which the result is shown for ten seconds unless the switch is triggered for another roll. To preserve power, Power down mode is entered after inactivity in Demo mode or Roll mode. Press any button to revive.

Dependencies:   mbed

Fork of mBuino_Dice by Valentin Ivanov

mBuino_Dice

The hardware: No soldering required

As you can see in the picture gallery below, this is a very simple mBuino project, requiring only one extra component: a switch such as a push button or a tilt switch.

Push button

The push-button I used fits neatly between P0.4 and GND. By just bending the legs flat to the PCB, the button attached sturdy enough to make a usable connection.

Tilt switch

The tilt switch version is much more fun. No pushing, just a shake to roll the dice! In the tilt switch version two short wires were used to connect the switch. The wires were twisted around the legs of the tilt switch without any soldering! By adjusting the horizontal level of the switch you can make the dice react more sensitively to small movement.

For a production version, I would of course make it all a bit more durable by soldering the connections and using hot glue to keep everything in place. But going that route, I would also want to make a nicely fitting box, perhaps use other LEDs in a traditional dice-eye position and add an on-off switch...

Committer:
Architect
Date:
Wed Jul 23 19:02:43 2014 +0000
Revision:
0:5d9ccbe9d49d
Child:
1:38fcbf88615a
Initial version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Architect 0:5d9ccbe9d49d 1 #include "mbed.h"
Architect 0:5d9ccbe9d49d 2 //#include "rtos.h"
Architect 0:5d9ccbe9d49d 3
Architect 0:5d9ccbe9d49d 4 float delayTime = .05;
Architect 0:5d9ccbe9d49d 5
Architect 0:5d9ccbe9d49d 6 DigitalOut LED[] = {(P0_7), (P0_8), (P0_2), (P0_20), (P1_19), (P0_17), (P0_23)};// declare 7 LEDs
Architect 0:5d9ccbe9d49d 7
Architect 0:5d9ccbe9d49d 8 int main()
Architect 0:5d9ccbe9d49d 9 {
Architect 0:5d9ccbe9d49d 10 int i = 0;
Architect 0:5d9ccbe9d49d 11 while( i < 10 ) {
Architect 0:5d9ccbe9d49d 12 for(int x = 0; x < 7; x++) {
Architect 0:5d9ccbe9d49d 13 LED[x] = 1; // turn on
Architect 0:5d9ccbe9d49d 14 wait(delayTime); // delay
Architect 0:5d9ccbe9d49d 15 }
Architect 0:5d9ccbe9d49d 16 for(int x = 0; x < 7; x++) {
Architect 0:5d9ccbe9d49d 17 LED[x] = 0; // turn off
Architect 0:5d9ccbe9d49d 18 wait(delayTime); // delay
Architect 0:5d9ccbe9d49d 19 }
Architect 0:5d9ccbe9d49d 20 for(int x = 6; x >= 0; x--) {
Architect 0:5d9ccbe9d49d 21 LED[x] = 1; // turn on
Architect 0:5d9ccbe9d49d 22 wait(delayTime); // delay
Architect 0:5d9ccbe9d49d 23 }
Architect 0:5d9ccbe9d49d 24 for(int x = 6; x >= 0; x--) {
Architect 0:5d9ccbe9d49d 25 LED[x] = 0; // turn off
Architect 0:5d9ccbe9d49d 26 wait(delayTime); // delay
Architect 0:5d9ccbe9d49d 27 }
Architect 0:5d9ccbe9d49d 28
Architect 0:5d9ccbe9d49d 29 i++;
Architect 0:5d9ccbe9d49d 30 }
Architect 0:5d9ccbe9d49d 31
Architect 0:5d9ccbe9d49d 32 //Thread::wait(osWaitForever);
Architect 0:5d9ccbe9d49d 33 }