Skip to content

Commit 21819e8

Browse files
committed
docs : 7세그먼트
- anode(양극) type : 자리선택 "1", 세그먼트 켜기 "0", 공통핀:VCC, 제어핀: GND 인가 - cathod(음극) type : 자리선택 "0", 세그먼트 켜기 "1" 공통핀:GND, 제어핀: VCC인가해서 제어 - 8개 LED : 7세그먼트 + 소숫점 - 잔상효과
1 parent cdb9e32 commit 21819e8

File tree

1 file changed

+121
-11
lines changed

1 file changed

+121
-11
lines changed

부품&연결방법/7세그먼트.md

+121-11
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,156 @@
22

33
### ✔ 연결방법
44

5+
![image](https://user-images.githubusercontent.com/54584063/84397983-51e0f780-ac3a-11ea-89d3-17056457934f.png)
56

67
<br><br>
78

89
### ✔ 7세그먼트
910

1011
- 표시장치
1112

13+
- 8개의 LED = 7개 세그먼트 + 소숫점1개
14+
15+
- 2개 공통핀 + 8개 제어핀
16+
17+
- 공통 양극(Anode) 방식 : 0을 줘서 켬, 공통핀-VCC, 제어핀-GND 인가
18+
19+
- 공통 음극(Cathode) 방식 : 1을 줘서 켬, 공통핀-GND, 제어핀-VCC 인가하여 제어
20+
21+
1222
- 내부 구조
1323

24+
![image](https://user-images.githubusercontent.com/54584063/84394860-70de8a00-ac38-11ea-976a-7fdecec90005.png)
25+
1426
- 숫자 표시
1527

28+
![image](https://user-images.githubusercontent.com/54584063/84395053-b26f3500-ac38-11ea-8c97-95bf58b76881.png)
29+
30+
- 0표현 : abcdef = 음극 11111100 = 양극 00000011
31+
1632
- 제어 데이터
1733

34+
- 양극(Anode type) : 0을 줘서 켬, 공통핀VCC, 제어핀 GND인가
35+
36+
![image](https://user-images.githubusercontent.com/54584063/84396471-50fb9600-ac39-11ea-8ef4-d5464ef72c50.png)
37+
38+
- 음극(Cathode type) : 1을 줘서 켬, 공통핀 GND, 제어핀 VCC인가해서 제어
39+
40+
![image](https://user-images.githubusercontent.com/54584063/84397216-8c966000-ac39-11ea-89df-15d48654057a.png)
41+
1842
- 4자리
1943

2044
- 제어핀 수
2145

22-
- 잔상 효과 사용
46+
1자리 7세그먼트 제어를 위해 => 8개 제어핀 필요
2347

24-
- 구조
48+
4자리 7세그먼트 => 8 x 4 = 32개
2549

26-
- 3자리
50+
=> **"공유"** : 잔상효과 사용(Afterimage effect)
2751

28-
- 제어핀 수
2952

30-
- 잔상 효과 사용
53+
- 구조
3154

55+
"양극"에서 자리 선택 = 1, 세그먼트 켜기 = 0
56+
"음극"에서 자리 선택 = 0, 세그먼트 켜기 = 1
3257

58+
![image](https://user-images.githubusercontent.com/54584063/84397799-13e3d380-ac3a-11ea-8764-8ed1bd96f3da.png)
3359

34-
<br><br>
3560

36-
### ✔ LAB
61+
- 연결방법
3762

38-
- 1자리 숫자 표시
3963

40-
- 모든 자리 표시 및 0.1초 카운터
64+
<br><br>
4165

42-
- 시계 구현
66+
### ✔ LAB
67+
- 1자리 숫자 표시
68+
69+
```c
70+
//0에서 9까지 숫자 표현
71+
byte pattern[] = {
72+
0xFC, 0x60, 0xDA, 0xF2, 0x66, 0xB6, 0xBE, 0xE4, 0xFE, 0xE6
73+
};
74+
75+
//자릿수 선택 핀
76+
int digit_select_pin[] = {66,67,68,69};
77+
78+
//해당 자리에 숫자 하나 표시
79+
void show_digit(int pos, int number){ //(위치, 출력할 숫자)
80+
for (int i=0; i<4; i++){
81+
if(i+1 == pos){
82+
digitalWrite(digit_select_pin[i], LOW);
83+
}
84+
else{
85+
digitalWrite(digit_select_pin[i], HIGH)
86+
}
87+
}
88+
for (int i=0; i<8; i++){
89+
boolean on_off = bitRead(patterns[number], 7-i);
90+
digitalWrite(segment_pin[i], on_off);
91+
}
92+
93+
}
94+
```
95+
- 모든 자리 표시 및 0.1초 간격 카운터
96+
97+
```c
98+
// 4자리 7세그먼트 표시 장치에 4자리 숫자를 표시하는 함수
99+
void show_4_digit(int number) {
100+
number = number % 10000; // 4자리로 제한
101+
102+
int thousands = number / 1000; // 천 자리
103+
number = number % 1000;
104+
105+
int hundreads = number / 100; // 백 자리
106+
number = number % 100;
107+
108+
int tens = number / 10; // 십 자리
109+
int ones = number % 10; // 일 자리
110+
111+
show_digit(1, thousands);
112+
delay(SEGMENT_DELAY);
113+
show_digit(2, hundreads);
114+
delay(SEGMENT_DELAY);
115+
show_digit(3, tens);
116+
delay(SEGMENT_DELAY);
117+
show_digit(4, ones);
118+
delay(SEGMENT_DELAY);
119+
}
120+
void loop() {
121+
time_current = millis();
122+
if (time_current time_previous >= 100) {
123+
time_previous = time_current; count++;
124+
}
125+
show_4_digit(count);
126+
}
127+
```
128+
- 시계 구현
129+
130+
```c
131+
void loop() {
132+
time_current = millis();
133+
if (time_current - time_previous >= 1000) {// 1초 경과
134+
time_previous = time_current;
135+
seconds++; // 초 증가
136+
137+
if (seconds == 60) { // 60초가 되면 분 증가
138+
seconds = 0; minutes++;
139+
}
140+
if (minutes == 60) {
141+
minutes = 0; // 60분이 되면 0으로 되돌림
142+
}
143+
show_4_digit(minutes * 100 + seconds); // 시간 표시를 위해 4자리 숫자로 만듦
144+
}
145+
```
146+
- 가변저항 값 표시
147+
148+
```c
149+
void loop(){
150+
int reading = analogRead(A0);
151+
show_4_digit(reading); //가변저항 값 표시
152+
}
153+
```
43154

44-
- 가변저항 값 표시
45155

46156
<br><br>
47157

0 commit comments

Comments
 (0)