You are on page 1of 3

#i

ncl
ude"
Wir
e.h"

#def
ineDATA8

#def
ineLATCH9

#def
ineCLK10

consti
ntupBut
tonA=4;

consti
ntdownBut
tonA=5;

consti
ntupBut
tonB=2;

consti
ntdownBut
tonB=3;

i
ntupBut
tonSt
ate=0;

i
ntdownBut
tonSt
ate=0;

i
ntcont
rol
Var=0;

i
ntcount
Var=0;

charst
_sw_
upA=0;

charst
_sw_
downA=0;

charst
_sw_
upB=0;

charst
_sw_
downB=0;

i
ntscor
e_a=0,
scor
e_b=0;

i
nta,
b,
c,
d;
/
/bi
l
anganHEXAr
ray

by
tedi
git
[10]
={0xc0,
0xf
9,0xa4,
0xb0,
0x99,
0x92,
0x82,
0xf
8,0x
80,
0x90}
;

/
/{0x3F,
0x06,
0x5B,
0x4F,
0x66,
0x6D,
0x7D,
0x07,
0x7F,
0x6F}
;//sev
ensegmentcommonanoda

/
/{0xc0,
0xf
9,0xa4,
0xb0,
0x99,
0x92,
0x82,
0xf
8,0x80,
0x90}
;//sev
ensegmentcommoncat
hoda

i
nti
;

v
oidset
up(
){

pi
nMode(
LATCH,
OUTPUT)
;

pi
nMode(
CLK,
OUTPUT)
;

pi
nMode(
DATA,
OUTPUT)
;

pi
nMode(
upBut
tonA,
INPUT_
PULLUP)
;

pi
nMode(
downBut
tonA,
INPUT_
PULLUP)
;

pi
nMode(
upBut
tonB,
INPUT_
PULLUP)
;

pi
nMode(
downBut
tonB,
INPUT_
PULLUP)
;

v
oidl
oop(
){

i
f(di
git
alRead(
downBut
tonA)==LOW &&st
_sw_
downA==0){
scor
e_a-
-;
st_
sw_
downA=1;
del
ay(
100)
;}

i
f(di
git
alRead(
downBut
tonA)==HI
GH&&st
_sw_
downA==1){
st_
sw_
downA=0;
del
ay(
100)
;}

i
f(di
git
alRead(
upBut
tonA)==LOW &&st
_sw_
upA==0){
scor
e_a++;
st_
sw_
upA=1;
del
ay(
100)
;}

i
f(di
git
alRead(
upBut
tonA)==HI
GH&&st
_sw_
upA==1){
st_
sw_
upA=0;
del
ay(
100)
;}

i
f(di
git
alRead(
downBut
tonB)==LOW &&st
_sw_
downB==0){
scor
e_b-
-;
st_
sw_
downB=1;
del
ay(
100)
;}

i
f(di
git
alRead(
downBut
tonB)==HI
GH&&st
_sw_
downB==1){
st_
sw_
downB=0;
del
ay(
100)
;}

i
f(di
git
alRead(
upBut
tonB)==LOW &&st
_sw_
upB==0){
scor
e_b++;
st_
sw_
upB=1;
del
ay(
100)
;}

i
f(di
git
alRead(
upBut
tonB)==HI
GH&&st
_sw_
upB==1){
st_
sw_
upB=0;
del
ay(
100)
;}
i
f(scor
e_a>99){

scor
e_a=0;

i
f(scor
e_a<0){

scor
e_a=99;

i
f(scor
e_b>99){

scor
e_b=0;

i
f(scor
e_b<0){

scor
e_b=99;

a=scor
e_a/
10;

b=scor
e_a%10;

c=scor
e_b/
10;

d=scor
e_b%10;

di
git
alWr
it
e(LATCH,
LOW)
;

shi
ft
Out
(DATA,
CLK,
MSBFI
RST,
~di
git
[d]
);/
/di
git
empatsev
ensegment

shi
ft
Out
(DATA,
CLK,
MSBFI
RST,
~di
git
[c]
);/
/di
git
ti
gasev
ensegment

shi
ft
Out
(DATA,
CLK,
MSBFI
RST,
~di
git
[b]
);/
/di
git
duasev
ensegment

shi
ft
Out
(DATA,
CLK,
MSBFI
RST,
~di
git
[a]
);/
/di
git
sat
usev
ensegment

di
git
alWr
it
e(LATCH,
HIGH)
;

del
ay(
50)
;

You might also like