Digital Electronic Dice Project Games and Gaming

  • img
Project Details

Hey guys we are back with another cool CloudX project for you. It is a gaming dice project that allows more than 7 people to play. It's an easy and fun project, suitable for beginners and those who want to start with CloudX; it also requires a minimal amount of components. We plan to convert this protoboard project into a shield for cloudx. You can watch the project video on Youtube.

 

Material Used

The equipment you will need in this cloudx dice project is listed below.

  • CloudX M633
  • 2x Seven Segment Display
  • 7x 220 ohm Resistors
  • 10k ohm Resistor (for pullup)
  • PushButton switch
  • ProtoBoard.
  • Male and Female Header Connector.

 

Circuit Diagram

 

Board Connections

The two seven segment display used are multiplexed together (meaning 'a' of segment1 is connected to 'a' of segment2 and so on), only their commons (either anode or cathode) are not connected together. The buttons are connected to 'A0', each button gives different analog readings (1.67 and 3.33v respectively) when pressed. The project uses the Random Generator library for generating random numbers (pretty easy to use), ADC library for detecting which of the button pressed, conversion library for converting integer numbers to strings and segment library for displaying numbers on the seven segment display.

CloudX M633      |      Seven Segment pin 

P8                        |      C2 
P9                        |      C1 
P10                      |      B 
P11                      |      A 
P12                      |      E 
P13                      |      D 
P14                      |      C 
P15                      |      G 
P16                      |      F 
 

Code


#include <CloudX\RandomNumberGenerator.h>
#include <CloudX\ADC.h>
#include <CloudX\conversion.h>
#include <CloudX\Segment.h>



char NumberOfDigit = 2; //2 digits on display
char segmentDataPins[] = {11, 10, 14, 13, 12, 16, 15, NULL}; //a,b,c,d,e,f,g,dp
char segmentScanPins[] = {9, 8}; //scan pins
float read;

char txt[3]; char dice1, dice2;
char i;
setup(){
//setup here
Analog_setting();
Segment_setting(CCathode,NumberOfDigit,segmentScanPins,segmentDataPins);
pinMode(7, OUTPUT);
pinMode(5, OUTPUT);
digitalWrite(7, HIGH);
Segment_writeText("00", 100);
RandNumber_limit(1, 6);
loop(){
//Program here
read = Analog_read(0);
read = read * 5/1023;
if(read >= 1.60 && read <=1.73)
intTostr(txt,0,DEC);

if(read >= 3.0 && read <=3.7)
{
for(i=0; i<10; i++); {
intTostr(txt,i,DEC);
Segment_writeText(txt, 2);
}
dice1 = RandNumber_gen();
dice2 = RandNumber_gen();
dice1 = (dice1 *10)+dice2;
intTostr(txt,dice1,DEC);

}
Segment_writeText(txt, 3);

}
}

 

Testing

 

 

Share this with friends