๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ’ป Microprocessor/์บก์Šคํ†ค ์ฑŒ๋ฆฐ์ง€

[6์ฃผ์ฐจ] (Led Matrix) Capston Challenge

by GroovyArea 2022. 10. 13.

๋ฌธ์ œ 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);
  }
}
๋ฐ˜์‘ํ˜•