Toggle navigation
Toggle navigation
This project
Loading...
Sign in
공정훈
/
test
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
공정훈
2022-06-12 06:13:22 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8a432faf759d5d3e5a47da3c3c924a05a326bda3
8a432faf
1 parent
a11ecd73
FND stopwatch
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
0 deletions
iotsw2-4_2.c
iotsw2-4_2.c
0 → 100644
View file @
8a432fa
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <wiringPi.h>
const
int
FndSelectPin
[
6
]
=
{
23
,
22
,
27
,
18
,
17
,
4
};
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
;
int
flag
=
0
;
int
shift
=
0x01
;
for
(
i
=
0
;
i
<
8
;
i
++
)
{
if
(
position
==
3
&&
i
==
7
)
flag
=
1
;
else
flag
=
(
FndFont
[
num
]
&
shift
);
digitalWrite
(
FndPin
[
i
],
flag
);
shift
<<=
1
;
}
FndSelect
(
position
);
}
int
main
()
{
int
i
,
j
;
int
c
[
6
]
=
{
0
,
0
,
0
,
0
,
0
,
0
};
int
ptime
=
millis
();
Init
();
while
(
1
)
{
while
(
millis
()
-
ptime
<
10
)
{
for
(
i
=
0
;
i
<
6
;
i
++
)
{
FndDisplay
(
i
,
c
[
i
]);
delay
(
1
);
}
}
ptime
=
millis
();
c
[
5
]
++
;
for
(
j
=
5
;
j
>
0
;
j
--
)
{
c
[
j
-
1
]
+=
c
[
j
]
/
10
;
c
[
j
]
%=
10
;
}
c
[
0
]
%=
10
;
}
return
0
;
}
Please
register
or
login
to post a comment