1
키보드의 컨트롤러로 Sparkfun Pro Micro를 사용하려고합니다. 나는 정상적인 키보드 동작을 할 수 없다. 내 코드 :USB 키보드 컨트롤러로 Sparkfun Pro Micro (ATMega32u4)
#include <Keyboard.h>
int firstButtonPin = 18, secondButtonPin = 19;
char firstButtonChar = 'z', secondButtonChar = 'x';
bool firstButtonPressed = false, secondButtonPressed = true;
void setup() {
pinMode(firstButtonPin, INPUT);
pinMode(secondButtonPin, INPUT);
Keyboard.begin();
}
void loop() {
if(digitalRead(firstButtonPin) == HIGH && firstButtonPressed == false) Keyboard.press(firstButtonChar), firstButtonPressed = true;
else if(digitalRead(firstButtonPin) != HIGH && firstButtonPressed) Keyboard.release(firstButtonChar), firstButtonPressed = false;
if(digitalRead(secondButtonPin) == HIGH && secondButtonPressed == false) Keyboard.press(secondButtonChar), secondButtonPressed = true;
else if(digitalRead(secondButtonPin) != HIGH && secondButtonPressed) Keyboard.release(secondButtonChar), secondButtonPressed = false;
}
YT 링크 : https://youtu.be/VfHNOtq4HHo입니다. 보시다시피 일반 키보드는 단일 키를 출력하고 잠시 후 스팸 메일을 보냅니다. AVR을 전환 할 때마다 스팸이 계속 발생합니다 (키가 누락되지 않고 잠시 눌렀다가 놓아지는 것처럼 보입니다.) 어떻게 실제 키보드의 동작을 얻을 수 있습니까? 사용하고 싶습니다. 오우 스와 같은 게임에서! 도와주세요. 미리 감사드립니다.