我正在尝试让我的Adafruit小饰品用作键盘。我使用的是标准示例代码,但它一直给我这个编译错误。
exit status 1
'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
即使我的代码中有此错误,该错误也会不断弹出。我已经尝试了很多不同版本的程序,并弄乱了很多东西,但总是会出现此错误。
这是我的代码。
#include <Keyboard.h>
const int buttonPin = 4; // input pin for pushbutton
int previousButtonState = HIGH; // for checking the state of a pushButton
int counter = 0; // button push counter
void setup() {
// make the pushButton pin an input:
pinMode(buttonPin, INPUT);
// initialize control over the keyboard:
Keyboard.begin();
}
void loop() {
// read the pushbutton:
int buttonState = digitalRead(buttonPin);
// if the button state has changed,
if ((buttonState != previousButtonState)
// and it's currently pressed:
&& (buttonState == HIGH)) {
// increment the button counter
counter++;
// type out a message
Keyboard.print("You pressed the button ");
Keyboard.print(counter);
Keyboard.println(" times.");
}
// save the current button state for comparison next time:
previousButtonState = buttonState;
}
答案 0 :(得分:0)
void swap(int *x, int *y) {
int temp;
temp = *x;
*x = *y;
*y = temp;
}
int main() {
int a=10, b=20;
swap(a, b);
printf("a: %d, b: %d", a, b);
}
库用于具有本地USB支持的官方Arduino开发板。
对于小饰品,您需要使用TrinketKeyboard.h
from Adafruit。