Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이다은
/
raspberry
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
daeun
2021-04-23 14:37:16 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
74222898e70b7a8943965b3060dfef0a7bc50b43
74222898
1 parent
e0ea86a7
mid
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
12 deletions
midterm4.c
midterm4.c
View file @
7422289
...
...
@@ -6,6 +6,10 @@ const int FndSelectPin[6] = { 4, 17, 18, 27, 22, 23 };
const
int
FndPin
[
8
]
=
{
6
,
12
,
13
,
16
,
19
,
20
,
26
,
21
};
const
int
FndFont
[
10
]
=
{
0x3F
,
0x06
,
0x5B
,
0x4F
,
0x66
,
0x6D
,
0x7D
,
0x07
,
0x7F
,
0x67
};
const
int
Keypad
[
3
]
=
{
11
,
9
,
10
};
int
time
=
0
;
int
data
[]
=
{
0
,
0
,
0
,
0
,
0
,
0
};
int
state
=
2
;
void
init
(){
int
i
;
...
...
@@ -21,6 +25,26 @@ void init(){
pinMode
(
FndPin
[
i
],
OUTPUT
);
digitalWrite
(
FndPin
[
i
],
LOW
);
}
for
(
i
=
0
;
i
<
3
;
i
++
)
pinMode
(
Keypad
[
i
],
INPUT
);
if
(
wiringPiISR
(
Keypad
[
1
],
INT_EDGE_FALLING
,
&
stop
)
<
0
)
{
return
1
;
}
if
(
wiringPiISR
(
Keypad
[
2
],
INT_EDGE_FALLING
,
&
reset
)
<
0
)
{
return
1
;
}
}
int
KeypadRead
()
{
int
i
,
keypadnum
=
-
1
;
for
(
i
=
0
;
i
<
3
;
i
++
)
{
if
(
!
digitalRead
(
Keypad
[
i
]))
{
state
=
1
;
keypadnum
=
i
;
break
;
}
}
return
keypadnum
;
}
void
FndSelect
(
int
position
){
int
i
;
...
...
@@ -48,22 +72,40 @@ void FndDisplay(int position, int num){
}
FndSelect
(
position
);
}
int
main
()
{
void
timer
()
{
int
pos
;
int
time
=
0
;
for
(
pos
=
0
;
pos
<
6
;
pos
++
)
{
FndDisplay
(
pos
,
data
[
pos
]);
delay
(
1
);
}
}
void
stop
()
{
timer
();
state
=
1
;
}
void
reset
()
{
time
=
0
;
state
=
2
;
}
int
main
(){
init
();
unsigned
long
prevtime
=
millis
();
while
(
1
){
unsigned
long
curtime
=
millis
();
if
(
curtime
-
prevtime
>=
9
){
prevtime
=
curtime
;
if
(
KeypadRead
()
==
0
)
{
state
=
0
;
unsigned
long
prevtime
=
millis
();
while
(
1
)
{
unsigned
long
curtime
=
millis
();
if
(
curtime
-
prevtime
>=
9
)
{
prevtime
=
curtime
;
time
++
;
}
int
data
[
6
]
=
{
time
%
10
,
(
time
%
100
)
/
10
,
(
time
%
1000
)
/
100
,
(
time
/
1000
)
%
10
,
(
time
/
10000
)
%
10
,
time
/
100000
};
for
(
pos
=
0
;
pos
<
6
;
pos
++
){
FndDisplay
(
pos
,
data
[
pos
]);
delay
(
1
);
data
[
6
]
=
{
time
%
10
,
(
time
%
100
)
/
10
,
(
time
%
1000
)
/
100
,
(
time
/
1000
)
%
10
,
(
time
/
10000
)
%
10
,
time
/
100000
};
timer
();
}
}
else
if
(
state
>
0
)
{
while
(
1
)
{
timer
();
}
}
return
0
;
...
...
Please
register
or
login
to post a comment