Toggle navigation
Toggle navigation
This project
Loading...
Sign in
정현희
/
es
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
정현희
2017-03-21 22:03:47 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7ea3c749c11fe5ff3d46addca5ac6e7370f48770
7ea3c749
0 parents
FND 프로그래밍
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
lab04.c
lab04.c
0 → 100644
View file @
7ea3c74
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
int
main
()
{
unsigned
char
FND_DATA
[]
=
{
0x3f
,
0x06
,
0x5b
,
0x4f
,
0x66
,
0x6d
,
0x7d
,
0x27
,
0x7f
,
0x6f
,
0x77
,
0x7c
,
0x39
,
0x5e
,
0x79
,
0x71
,
0x80
,
0x40
,
0x08
};
// 0~9, A~F, '.', '-', '_'
unsigned
int
num
=
0
,
num0
,
num1
,
num2
,
num3
;
// 각 자리 수를 나타내기 위한 변수
DDRC
=
0xff
;
// C포트를 모두 사용
DDRG
=
0x0f
;
// 분/초 시계
unsigned
int
i
=
0
;
// 0.5초 마다 깜빡거리는 것을 설정하기 위한 변수
while
(
1
)
{
num
++
;
num0
=
(
num
/
60000
)
%
6
;
// 각 자리 수 마다 연산
num1
=
(
num
/
6000
)
%
10
;
num2
=
(
num
/
1000
)
%
6
;
num3
=
(
num
/
100
)
%
10
;
PORTC
=
FND_DATA
[
num0
];
PORTG
=
0x08
;
_delay_ms
(
2
);
PORTC
=
FND_DATA
[
num1
]
+
0x80
;
// 가운데 점 표시
PORTG
=
0x04
;
_delay_ms
(
2
);
if
(
i
<
40
)
PORTC
=
FND_DATA
[
num2
];
else
PORTC
=
0
;
PORTG
=
0x02
;
_delay_ms
(
3
);
if
(
i
<
40
)
PORTC
=
FND_DATA
[
num3
];
else
PORTC
=
0
;
PORTG
=
0x01
;
_delay_ms
(
3
);
if
(
i
++
>=
50
)
// 0.5초 마다 i를 0으로 초기화하여 깜빡거리도록 설정
i
=
0
;
}
}
Please
register
or
login
to post a comment