Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- vi
- 아두이노
- Winform
- Google Drive API
- 우분투 opencv 설치
- rotation
- google drive 업로드
- 고정ip할당
- opencv
- 정보처리기사
- opencv resize
- Python
- vim
- NodeMCU
- vim명령어
- sshkey
- ubuntu
- vtk
- apt update
- c#
- opengl
- esp32
- opencv apt설치
- api사용해서 google drive에 폴더만들기
- annotating
- google drive upload
- translation
- libopencv-dev
- 아두이노 설치
- 정보처리기사후기
Archives
- Today
- Total
내가 보려고 만든 블로그
아두이노 7세그먼트(7segment led) 본문
반응형
은근 연결하기힘들다 10개나 연결.. 1k옴 사용해야함.
#define ledA 8
#define ledB 9
#define ledC 2
#define ledD 3
#define ledE 4
#define ledF 6
#define ledG 5
void setup()
{
//각각의 핀들을 OUTPUT으로 설정해 준다.
pinMode(ledA, OUTPUT);
pinMode(ledB, OUTPUT);
pinMode(ledC, OUTPUT);
pinMode(ledD, OUTPUT);
pinMode(ledE, OUTPUT);
pinMode(ledF, OUTPUT);
pinMode(ledG, OUTPUT);
Serial.begin(9600); //시리얼 모니터 설정.
}
void loop()
{
Serial.println("Starting\n");
LoopDisplay(); //LoopDisplay 함수 실행.
}
/*
A~F, 0~9까지 표시하는 함수
7개의 LED를 HIGH(켜짐)/LOW(꺼짐)으로 설정하여 표시한다.
*/
void clr()
{
//Clears the LED
digitalWrite(ledA, LOW);
digitalWrite(ledB, LOW);
digitalWrite(ledC, LOW);
digitalWrite(ledD, LOW);
digitalWrite(ledE, LOW);
digitalWrite(ledF, LOW);
digitalWrite(ledG, LOW);
}
void char_A()
{
digitalWrite(ledD, LOW);
digitalWrite(ledE, HIGH);
digitalWrite(ledF, HIGH);
digitalWrite(ledG, HIGH);
digitalWrite(ledA, HIGH);
digitalWrite(ledB, HIGH);
digitalWrite(ledC, HIGH);
}
void char_B()
{
//Displays B
digitalWrite(ledD, HIGH);
digitalWrite(ledE, HIGH);
digitalWrite(ledF, HIGH);
digitalWrite(ledG, HIGH);
digitalWrite(ledA, HIGH);
digitalWrite(ledB, HIGH);
digitalWrite(ledC, HIGH);
}
void char_C()
{
//Displays C
digitalWrite(ledD, HIGH);
digitalWrite(ledE, HIGH);
digitalWrite(ledF, HIGH);
digitalWrite(ledG, LOW);
digitalWrite(ledA, HIGH);
digitalWrite(ledB, LOW);
digitalWrite(ledC, LOW);
}
void char_D()
{
//Displays D
digitalWrite(ledD, HIGH);
digitalWrite(ledE, HIGH);
digitalWrite(ledF, HIGH);
digitalWrite(ledG, LOW);
digitalWrite(ledA, HIGH);
digitalWrite(ledB, HIGH);
digitalWrite(ledC, HIGH);
}
void char_E()
{
//Displays E
digitalWrite(ledD, HIGH);
digitalWrite(ledE, HIGH);
digitalWrite(ledF, HIGH);
digitalWrite(ledG, HIGH);
digitalWrite(ledA, HIGH);
digitalWrite(ledB, LOW);
digitalWrite(ledC, LOW);
}
void char_F()
{
//Displays F
digitalWrite(ledD, LOW);
digitalWrite(ledE, HIGH);
digitalWrite(ledF, HIGH);
digitalWrite(ledG, HIGH);
digitalWrite(ledA, HIGH);
digitalWrite(ledB, LOW);
digitalWrite(ledC, LOW);
}
void one()
{
//Displays 1
digitalWrite(ledD, LOW);
digitalWrite(ledE, LOW);
digitalWrite(ledF, LOW);
digitalWrite(ledG, LOW);
digitalWrite(ledA, LOW);
digitalWrite(ledB, HIGH);
digitalWrite(ledC, HIGH);
}
void two()
{
//Displays 2
digitalWrite(ledD, HIGH);
digitalWrite(ledE, HIGH);
digitalWrite(ledF, LOW);
digitalWrite(ledG, HIGH);
digitalWrite(ledA, HIGH);
digitalWrite(ledB, HIGH);
digitalWrite(ledC, LOW);
}
void three()
{
//Displays 3
digitalWrite(ledD, HIGH);
digitalWrite(ledE, LOW);
digitalWrite(ledF, LOW);
digitalWrite(ledG, HIGH);
digitalWrite(ledA, HIGH);
digitalWrite(ledB, HIGH);
digitalWrite(ledC, HIGH);
}
void four()
{
//Displays 4
digitalWrite(ledD, LOW);
digitalWrite(ledE, LOW);
digitalWrite(ledF, HIGH);
digitalWrite(ledG, HIGH);
digitalWrite(ledA, LOW);
digitalWrite(ledB, HIGH);
digitalWrite(ledC, HIGH);
}
void five()
{
//Displays 5
digitalWrite(ledD, HIGH);
digitalWrite(ledE, LOW);
digitalWrite(ledF, HIGH);
digitalWrite(ledG, HIGH);
digitalWrite(ledA, HIGH);
digitalWrite(ledB, LOW);
digitalWrite(ledC, HIGH);
}
void six()
{
//Displays 6
digitalWrite(ledD, HIGH);
digitalWrite(ledE, HIGH);
digitalWrite(ledF, HIGH);
digitalWrite(ledG, HIGH);
digitalWrite(ledA, HIGH);
digitalWrite(ledB, LOW);
digitalWrite(ledC, HIGH);
}
void seven()
{
//Displays 7
digitalWrite(ledD, LOW);
digitalWrite(ledE, LOW);
digitalWrite(ledF, LOW);
digitalWrite(ledG, LOW);
digitalWrite(ledA, HIGH);
digitalWrite(ledB, HIGH);
digitalWrite(ledC, HIGH);
}
void eight()
{
//Displays 8
digitalWrite(ledD, HIGH);
digitalWrite(ledE, HIGH);
digitalWrite(ledF, HIGH);
digitalWrite(ledG, HIGH);
digitalWrite(ledA, HIGH);
digitalWrite(ledB, HIGH);
digitalWrite(ledC, HIGH);
}
void nine()
{
//Displays 9
digitalWrite(ledD, HIGH);
digitalWrite(ledE, LOW);
digitalWrite(ledF, HIGH);
digitalWrite(ledG, HIGH);
digitalWrite(ledA, HIGH);
digitalWrite(ledB, HIGH);
digitalWrite(ledC, HIGH);
}
void zero()
{
//Displays 0
digitalWrite(ledD, HIGH);
digitalWrite(ledE, HIGH);
digitalWrite(ledF, HIGH);
digitalWrite(ledG, LOW);
digitalWrite(ledA, HIGH);
digitalWrite(ledB, HIGH);
digitalWrite(ledC, HIGH);
}
//모든 문자와 숫자를 순서대로 Display한다.
void LoopDisplay()
{
char_A();
delay(1000);
char_B();
delay(1000);
char_C();
delay(1000);
char_D();
delay(1000);
char_E();
delay(1000);
char_F();
delay(1000);
one();
delay(1000);
two();
delay(1000);
three();
delay(1000);
four();
delay(1000);
five();
delay(1000);
six();
delay(1000);
seven();
delay(1000);
eight();
delay(1000);
nine();
delay(1000);
zero();
delay(1000);
}
반응형
'아두이노' 카테고리의 다른 글
Nodemcu 와이파이 연결하기1 (0) | 2020.12.04 |
---|---|
NodeMCU 보드 사용해보기 (0) | 2020.12.04 |
아두이노 5v Relay (0) | 2020.09.08 |
아두이노 시계 (0) | 2020.09.08 |
아두이노 ds1302 realtime_clock (0) | 2020.09.08 |