0% found this document useful (0 votes)
21 views3 pages

Digital Dice with 8051 Microcontroller

This document describes a program to create a digital dice using an 8051 microcontroller. The program uses interrupts to implement pause and reset functions. It defines constants for the hexadecimal values corresponding to dice numbers 1-6. The main function continuously increments the current number and displays it on Port 2, looping back to 0 after 6. It uses delays to simulate rolling. Pause and reset interrupts can reset the number using buttons.

Uploaded by

Salaar Khan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views3 pages

Digital Dice with 8051 Microcontroller

This document describes a program to create a digital dice using an 8051 microcontroller. The program uses interrupts to implement pause and reset functions. It defines constants for the hexadecimal values corresponding to dice numbers 1-6. The main function continuously increments the current number and displays it on Port 2, looping back to 0 after 6. It uses delays to simulate rolling. Pause and reset interrupts can reset the number using buttons.

Uploaded by

Salaar Khan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

[Link] S.

Kavedia – 9860174297 – 9324258878 –


profmanojkavedia@[Link]

Digital dice using 8051 microcontroller


(AT89C51)
// 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;
[Link] S. Kavedia – 9860174297 – 9324258878 –
profmanojkavedia@[Link]

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;
}
[Link] S. Kavedia – 9860174297 – 9324258878 –
profmanojkavedia@[Link]

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++;
}

You might also like