All of us have played the game of gambling and are well aware of the working of the dice. Here we are presenting a circuit to make a electronic digital dice with the help of a seven segment controlled by an 8051 microcontroller. We have already gone through the seven segment circuit interfacing (refer ‘interfacing seven segment’ section). The circuit can be divided into two units: the microcontroller unit and the seven segment unit. The microcontroller unit contains a microcontroller circuit (for microcontroller circuit details, refer ‘led blinking’ section) and the seven segment unit contains a seven segment circuit which is interfaced to the controller (for more details of seven segment circuit, refer ‘seven segment interfacing’ section). This circuit displays the numbers from 1 to 6 continuously and it halts at the position user wants and starts again from the same position with the next instruction of the user.
Project Source Code
###
// Program to make a digital dice #include<reg51.h> sbit reset=P3^3; sbit start=P1^1; sbit pause=P3^2; sbit enable=P1^0; int current=0; char num[]={0xF9,0x24,0x30,0x19,0x12,0x02}; // Hex values corresponding to1to6 void delay(int time) // Function to generate time delay { int i,j; for(i=0;i<time;i++) for(j=0;j<1275;j++); } void pausefn()interrupt 0 //Pause function using external interrupt 0 { IE=0x84; P2=num[current]; while(1) { if( start==0 ) break; if(reset==0) { enable=1; current=0; P2=num[current]; while(start==1); return; } enable=1; delay(25); if( start==0) break; if(reset==0) { enable=1; current=0; P2=num[current]; while(start==1); return; } enable=0; delay(25); } enable=1; } void resetfn()interrupt 2 // Reset function using timer interrupt 2 { current=0; P2=num[current]; while(start==1); enable=1; } void main() { enable=1; while(1) { IE=0x85; if(current >5) { current=0; } P2=num[current]; delay(15); current++; } }###
Circuit Diagrams
Project Components
Project Video
Filed Under: 8051 Microcontroller
Filed Under: 8051 Microcontroller
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.