DoctorMX用のスイッチをまた作る

以前の DoctorMX用のスイッチを作る という記事が、Arduino側の仕様がだいぶ変わってしまって通じなくなっていたので再掲。
今度は、Pololu astar32u4 microです。

スケッチはこちら。
#define BUTTON_PIN 12
#define LED_PIN 13
int reading;
int prevRead = HIGH;
void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(LED_PIN,OUTPUT);
digitalWrite(LED_PIN,HIGH);
Keyboard.begin();
}
void loop(){
reading = digitalRead(BUTTON_PIN);
if(!reading){
if(prevRead) {
Keyboard.press(KEY_DOWN_ARROW);
digitalWrite(LED_PIN,LOW);
delay(100);
Keyboard.releaseAll();
digitalWrite(LED_PIN,HIGH);
}
}
prevRead = reading;
delay(10);
}
view raw USBKeyMono.ino hosted with ❤ by GitHub

コメント