ELECTRONIC DICE USING CLOUDX M633

We must all have played the game of chance in one way or the other using the dice. Knowing the very unpredictable nature of what the rolling of the dice would turn out to display further adds much fun game.

i hereby, present an electronic digital dice using simple LEDs, a push button and the CloudX M633 module to implement it.

Step 1: COMPONENTS

  • CloudX M633
  • CloudX softcard
  • Leds
  • Resistors(100r, 10k)
  • BreadBoard
  • Jumper wire
  • push-button
  • V3 cord

Step 2: LEDS

The light emitting diodes (LEDs) are the special kind of diodes that glow when current pass through them. Only that utmost care is taken limit the actual amount of current that is passed through them so as to avoid inadvertently damaging them in the process.

Step 3: Interfacing the LEDs With CloudX M633

The whole circuit is made up of two sections: the microcontroller and the LED sections respectively. The LEDs are organized in two sets with each −(comprising 7 LEDs), representing the normal faces of a dice; and are connected to pin P1 through to pin P14 of the MCU module.

The whole operation revolves round the microcontroller module as the heartbeat of the entire project. It (MCU) can be powered on:

  • either via the VIN and the GND points (ie. connecting them up to your external power-supply-unit’s +ve and –ve terminals respectively) on the board;
  • or through your CloudX USB softcard module.

As clearly illustrated in the schematic diagram above, the LEDs are arranged in such a way that when they light up, they indicate the numbers as they would in a real dice. And we are working with two sets of LEDs to represent two separate dice pieces. All of them are connected in the current sinking mode.

The first group of LEDs comprising: D1, D2, D3, D4, D5, D6, and D7; are connected to the MCU’s pins: P1, P2, P3, P4, P5, P6, and P7 respectively via 10Ω resistors. Whereas the other group consisting of: D8, D9, D10, D11, D12, D13, and D14; are connected to the MCU’s pins: P9, P10, P11, P12, P13, P14, and P15 respectively via 10Ω resistors as well.

Then, the push-button switch SW1 −with which we make a random number generation via a switch press, is connected to the MCU’s pin P16 using a pull-up resistor of 10kΩ.

Step 4: ​Principles of Operation

At start up, the LEDs are normally all Off to indicate that the system is ready for a new random number to be generated for display. On switch press, a random number ranging between 1 and 6 is so generated and displays via the LEDs; and stay On pending when another switch-press is made again.

Step 5: CODING

#include <CloudX\M633.h>
#include <CloudX\randNumGenerator.h>
#define switch1 pin16 
#define pressed LOW
/*holds dice patterns to be outputed on the LEDs */
unsigned char die[] = {0, 0x08, 0x14, 0x1C, 0x55, 0x5D,0x77};
unsigned char i, dice1, dice2;
    
setup(){
           //setup here
           
           /*configures port pins as output */
           portMode(1, OUTPUT);  
           portMode(2, 0b10000000);  
           
           /*switches all the LEDs off at the start */
           portWrite(1, LOW);
           portWrite(2, LOW);
           
           randNumLimit(1, 6); //takes care of randomNumber generation range (ie. min, max)
    loop(){
           //Program here
           
           if(switch1 is pressed) {   
               while(switch1 is LOW);  //waits here until switch is released
               dice1 = randNumGen();   //generates a random number for dice1
               dice2 = randNumGen();
               portWrite(1, die[dice1]);  //fetches the correct dice pattern and displays it
               portWrite(2, die[dice2]);  
}
           else
           {
              portWrite(1, die[dice1]); 
              portWrite(2, die[dice2]);   }
      }
}   //End of Program

Share

    Recommendations

    • Big and Small Contest

      Big and Small Contest
    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • PCB Contest

      PCB Contest

    Discussions