printf("ho_tari\n");

EX03_Binary_LED_Interrupt 본문

Arduino

EX03_Binary_LED_Interrupt

호타리 2023. 9. 2. 12:40
#include "PinChangeInterrupt.h"

const int LED[6] = {8, 9, 10, 11, 12, 13};
const int SW_0 = 4;
int cnt = 0;

void SW_0_Pressed(void) {
  cnt++;
}

void setup() {
  // put your setup code here, to run once:
  for(int i = 0; i < 6; i++)
  {
    pinMode(LED[i], OUTPUT);
  } 
  
  attachPCINT(digitalPinToPCINT(SW_0), SW_0_Pressed, RISING);
}

void loop() {
  // put your main code here, to run repeatedly: 
  for(int i = 0; i < 6; i++)
  {
      digitalWrite(LED[i], cnt & (0x01 << i) ? HIGH : LOW);
  }
}

'Arduino' 카테고리의 다른 글

<프로젝트> 스마트 주차장  (0) 2023.09.02
EX02_DC_MOTOR  (0) 2023.09.02
EX01_Binary_LED  (0) 2023.09.02
17_Multi_Task  (0) 2023.09.02
16_Keypad_4x4  (0) 2023.09.02