아두이노를 이용한 발(판) 키보드(Foot control, foot pedal) 만들기

준비물
  • 발판 스위치 : 대형 인터넷 쇼핑몰에서 4,000원짜리로 구입
  • Nulsomino-HANA (Arduino LEONARDO 호환 모듈) : 아두이노 보드보다 싸다 20,000원
  • BBJ-65 점퍼 와이어(핀 타입)세트 : 5,500원
  • 투명 브레드보드 [ELB-80T] : 3,300원
코드

void setup() {
  // pullup resistor so it goes high unless
  // connected to ground:
  pinMode(5, INPUT_PULLUP);
  pinMode(9, INPUT_PULLUP);
  // initialize control over the keyboard:
  Keyboard.begin();
}

void loop() {
  while (digitalRead(5) == LOW && digitalRead(9) == LOW) {
    Keyboard.press(KEY_LEFT_CTRL);
    Keyboard.press(KEY_LEFT_SHIFT);
  }
  while (digitalRead(5) == HIGH && digitalRead(9) == LOW) {
    Keyboard.release(KEY_LEFT_CTRL);
    Keyboard.press(KEY_LEFT_SHIFT);
  }
  while (digitalRead(5) == LOW && digitalRead(9) == HIGH) {
    Keyboard.press(KEY_LEFT_CTRL);
    Keyboard.release(KEY_LEFT_SHIFT);
  }
  while (digitalRead(5) == HIGH && digitalRead(9) == HIGH) {
    Keyboard.release(KEY_LEFT_CTRL);
    Keyboard.release(KEY_LEFT_SHIFT);
  }
}

회로도


댓글