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 15:02:32 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9cc96280c8cee257881028dbe608a8400b7cca30
9cc96280
1 parent
b5337434
a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
lab2-4-2.c
lab2-4-2.c
0 → 100644
View file @
9cc9628
#include <wiringPi.h>
#include <stdio.h>
#include <stdlib.h>
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
};
void
init
(){
int
i
;
if
(
wiringPiSetupGpio
()
==
-
1
){
printf
(
"wiringPiSetupGpio() error
\n
"
);
exit
(
-
1
);
}
for
(
i
=
0
;
i
<
6
;
i
++
){
pinMode
(
FndSelectPin
[
i
],
OUTPUT
);
digitalWrite
(
FndSelectPin
[
i
],
HIGH
);
}
for
(
i
=
0
;
i
<
8
;
i
++
){
pinMode
(
FndPin
[
i
],
OUTPUT
);
digitalWrite
(
FndPin
[
i
],
LOW
);
}
}
void
FndSelect
(
int
position
){
int
i
;
for
(
i
=
0
;
i
<
6
;
i
++
){
if
(
i
==
position
){
digitalWrite
(
FndSelectPin
[
i
],
LOW
);
}
else
{
digitalWrite
(
FndSelectPin
[
i
],
HIGH
);
}
}
}
void
FndDisplay
(
int
position
,
int
num
){
int
i
,
number
;
int
flag
=
0
;
int
shift
=
0x01
;
number
=
FndFont
[
num
];
if
(
position
==
2
)
number
|=
0x80
;
for
(
i
=
0
;
i
<
8
;
i
++
){
flag
=
(
number
&
shift
);
digitalWrite
(
FndPin
[
i
],
flag
);
shift
<<=
1
;
}
FndSelect
(
position
);
}
int
main
(){
int
pos
;
int
time
=
0
;
init
();
unsigned
long
prevtime
=
millis
();
while
(
1
){
unsigned
long
curtime
=
millis
();
if
(
curtime
-
prevtime
>
10
){
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
);
}
}
return
0
;
}
\ No newline at end of file
Please
register
or
login
to post a comment