qspl 按键,收下吧,不谢
/*相关报道:http://www.twd.cc/32545
http://dorcel-handsoff.com/
qspl
pin10 接地就开始按"QSPL"键
用mega32u4,leonardo
by:wxws
05-10-15
*/
int buttonPin = 10;
int ledPin = 17;
int keyisp = 0;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
Keyboard.begin();
}
void loop()
{
LedBlink();
if (digitalRead(buttonPin) == LOW)
{
if(keyisp == 0)
{
keyisp = 1;
//Keyboard.releaseAll();
Keyboard.write(' ');
delay(200);
Keyboard.press('q');
delay(100);
Keyboard.press('s');
delay(100);
Keyboard.press('p');
delay(100);
Keyboard.press('l');
}
}
else
{
if (keyisp == 1)
{
Keyboard.releaseAll();
keyisp = 0;
}
}
}
void LedBlink()
{
static int Ledvalue = 0; //LED上一状态
static long previousMillis = 0; //
static long skip = 1000;
if ( millis() - previousMillis > skip)
{
skip = keyisp ? 300 : 1000;
Ledvalue = 1 - Ledvalue;
digitalWrite(ledPin, Ledvalue);
previousMillis = millis();
}
} 其实找个重点地东西压着就好了:lol 哈哈,你们就是这样看yellow片的吗? Keyboard库在哪里?
页:
[1]