๋ฌธ์ 1
- ๋ง์ง๋ง ํ๋ง์ On
๋ฌธ์ ์ดํด
- ์ ๋ ธ๋ ํ์ ์ ์ด์ฉ
- row : high, col : low ์ผ๋ led on ๋๋ ๊ฒ์ ๋ช ์ฌํ์
์ฝ๋
int pin[17] = { -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37 };
int col[8] = { pin[9], pin[10], pin[11], pin[12], pin[13], pin[14], pin[15], pin[16] };
int row[8] = { pin[1], pin[2], pin[3], pin[4], pin[5], pin[6], pin[7], pin[8] };
void setup() {
// put your setup code here, to run once:
for (int i = 1; i <= 16; i++) {
pinMode(pin[i], OUTPUT);
}
}
void loop() {
// put your main code here, to runiuj8i repeatedly:
// row : high, col : low ์ผ๋ led On!
digitalWrite(row[7], HIGH);
for (int i = 1; i < 8; i++) {
digitalWrite(col[i], LOW);
}
}
๋ฌธ์ 2
- ๋ง์ง๋ง ๋ํธ ๋ถํฐ ์ฒซ ๋ํธ๊น์ง ๋ํธ ๋ณ ์ด๋ํ๋ฉด์ on
๋ฌธ์ ์ดํด
- ์ด์ค ๋ฐ๋ณต๋ฌธ์ ๋๋ ค ํน์ dot ์์ on
์ฝ๋
int pin[17] = { -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37 };
int col[8] = { pin[9], pin[10], pin[11], pin[12], pin[13], pin[14], pin[15], pin[16] };
int row[8] = { pin[1], pin[2], pin[3], pin[4], pin[5], pin[6], pin[7], pin[8] };
void setup() {
// put your setup code here, to run once:
for (int i = 1; i <= 16; i++) {
pinMode(pin[i], OUTPUT);
}
}
void loop() {
// put your main code here, to runiuj8i repeatedly:
// row : high, col : low ์ผ๋ led On!
for (int i = 7; i >= 0; i--) {
for (int k = 7; k >= 0; k--) {
dot_led(i, k);
delay(500);
}
}
}
void dot_led(int row_led, int col_led) {
for (int m = 0; m < 8; m++) {
digitalWrite(row[m], LOW);
digitalWrite(col[m], HIGH);
}
digitalWrite(row[row_led], HIGH);
digitalWrite(col[col_led], LOW);
}
๋ฌธ์ 3
- ์ฒซํ ๋ถํฐ ๋ง์ง๋ง ํ๊น์ง ๋์ onํ๊ณ , ๋ค์ ์ฒซํ์ผ๋ก off ๋ฐ๋ณต
๋ฌธ์ ์ดํด
- ์ด์ค ๋ฐ๋ณต๋ฌธ์ ๋๋ ค์ on
- ๋ฒ์๋ฅผ ๋ณ๊ฒฝํ์ฌ off
์ฝ๋
int pin[17] = { -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37 };
int col[8] = { pin[9], pin[10], pin[11], pin[12], pin[13], pin[14], pin[15], pin[16] };
int row[8] = { pin[1], pin[2], pin[3], pin[4], pin[5], pin[6], pin[7], pin[8] };
void setup() {
for (int i = 1; i <= 16; i++) {
pinMode(pin[i], OUTPUT);
}
}
void loop() {
// row : high, col : low ์ผ๋ led On!
// ์ด๊ธฐํ
for (int m = 0; m < 8; m++) {
digitalWrite(row[m], LOW);
digitalWrite(col[m], HIGH);
}
for (int i = 0; i < 8; i++) {
digitalWrite(row[i], HIGH);
for (int j = 0; j < 8; j++) {
digitalWrite(col[j], LOW);
}
delay(200);
}
for (int i = 7; i >= 0; i--) {
digitalWrite(row[i], LOW);
for (int j = 7; j >= 0; j--) {
digitalWrite(col[j], LOW);
}
delay(200);
}
}
๋ฐ์ํ
'๐ป Microprocessor > ์บก์คํค ์ฑ๋ฆฐ์ง' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[5์ฃผ์ฐจ] (Timer Counter Interrupt) Capston Challenge (0) | 2022.10.09 |
---|---|
[2์ฃผ์ฐจ] (External Interrupt) Caston Challenge 4 (2) | 2022.10.05 |
[2์ฃผ์ฐจ] Capston challenge 1 (0) | 2022.09.12 |