Department Of Computer Science
Project Report
MICRO Controller
Programming
Group Members
Aqib Hussain
SAP
8610
Feroze Khan
SAP
8633
Semester
6th
Submitted to
Sir Rana Marwat
Riphah Institutes of computing
and applied sciences the Lahore campus
Digital Dice
Introduction
Digital dice is an ARDUINO base project which show random numbers on
seven segment display. These random numbers are in between 1 to 6 and used for
the tabletop games. Through digital dice we will not use any object to create
random number rather we use ARDUINO technology to show random number on seven
segment led.
Background
In
traditional dice, small throw-able objects are used to produce random event.
When ARDUINO technology emerge there are many possibilities to convert many
system in digital devices to get efficient result without any problem. So,
digital dice is developed in order to attach its module to a systems, generate
random numbers.
Process of development
To develop this project we working on different phases. The most
important phase is that we train himself for this project by taking many
university labs and online tutorials. We learn how to make a proper circuits
and programming the ARDUINO with its components. After that we divided project
into two main category which are
·
Hardware part
·
Software part
In hardware part we focused
on circuit and component of project. We attached them with proper circuit and
make sure this circuit would work when we start it. In software part we make modules for different purposes and implement
them by making different methods.
Working
When project simulation start, we can press push button switch which
send a digital signal. Digital signal transfer to ARDUINO UNO, ARDUINO will
generate seven digital signals according to animation method and transfer them
towards seven digital ports. When 7 segment led accept signals it will display
spinning animation. After one rotation of spin complete then ARDUINO UNO send
digital signals toward seven ports according to the random number in between 1
to 6. 7 segment led accept these signals and display a random number pattern.
Future
This project needs lot of modification to improve its programing
efficiency as well as it physical structure. Algorithm which base on better
data structure can generate desire results with more efficiency. For this
purpose, the methods of program will be introduce with concept of 1d or 2d
arrays. With help of local industries we asked them to make plastic box case
with proper shape to put the circuit in it for amazing look of our digital
dice. We can make digital dice on commercial level and distribute them in
market.
1
Project Link & Code:
The project link of Tinkercad mention below:
https://www.tinkercad.com/things/9cyxnA20Vpv-amazing-rottis-densor/editel?sharecode=NDQzWs_bwkd_S4yt8GZXI6A0arke30ss0uG4DfVakc8
Code:
int a = 2; //For displaying segment "a"
int b = 3; //For displaying segment "b"
int c = 4; //For displaying segment "c"
int d = 5; //For displaying segment "d"
int e = 6; //For displaying segment "e"
int f = 8; //For displaying segment "f"
int g = 9; //For displaying segment "g"
#define buttonpin 7
int value=0;
void setup()
{
pinMode(a, OUTPUT); //A
pinMode(b, OUTPUT); //B
pinMode(c, OUTPUT); //C
pinMode(d, OUTPUT); //D
pinMode(e, OUTPUT); //E
pinMode(f, OUTPUT); //F
pinMode(g, OUTPUT); //G
turnoff();
pinMode(buttonpin,INPUT_PULLUP);
Serial.begin(9600);
randomSeed(analogRead(0));
}
void roll()
{
value=random(1,7);
Serial.println(value);
show(value);
}
void zero()
{
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,HIGH);
}
void one()
{
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
}
void two()
{ digitalWrite(f,HIGH);
digitalWrite(c,HIGH);
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(g,LOW);
}
void three()
{
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,LOW);
}
void four()
{
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
}
void five()
{
digitalWrite(a,LOW);
digitalWrite(b,HIGH);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,HIGH);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
}
void six()
{
digitalWrite(a,LOW);
digitalWrite(b,HIGH);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(g,LOW);
}
void spin()
{ digitalWrite(g,HIGH);
digitalWrite(a,LOW);
delay(250);
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
delay(250);
digitalWrite(b,HIGH);
digitalWrite(c,LOW);
delay(250);
digitalWrite(c,HIGH);
digitalWrite(d,LOW);
delay(250);
digitalWrite(d,HIGH);
digitalWrite(e,LOW);
delay(250);
digitalWrite(e,HIGH);
digitalWrite(f,LOW);
delay(250);
digitalWrite(f,HIGH);
digitalWrite(a,LOW);
delay(250);
digitalWrite(a,HIGH);
}
void turnoff()
{
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
}
void show(int value)
{
if(value==0)
{
zero();
}
else
if(value==1)
{
one();
}
else
if(value==2)
{
two();
}
else
if(value==3)
{
three();
}
else
if(value==4)
{
four();
}
else
if(value==5)
{
five();
}
else
if(value==6)
{
six();
}
}
int i=0;
void loop()
{
if(digitalRead(buttonpin)==LOW)
{
turnoff();
spin();
roll();
}
}
Post a Comment