Created
June 3, 2012 22:15
-
-
Save mitchtech/2865205 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Arduino USB HID Keyboard Demo | |
* Random Key/Random Delay | |
*/ | |
uint8_t buf[8] = { | |
0 }; /* Keyboard report buffer */ | |
void setup() | |
{ | |
Serial.begin(9600); | |
randomSeed(analogRead(0)); | |
delay(200); | |
} | |
void loop() | |
{ | |
int randomChar = random(4, 130); | |
long randomDelay = random(1000, 10000); | |
delay(randomDelay); | |
buf[2] = randomChar; // Random character | |
Serial.write(buf, 8); // Send keypress | |
releaseKey(); | |
} | |
void releaseKey() | |
{ | |
buf[0] = 0; | |
buf[2] = 0; | |
Serial.write(buf, 8); // Release key | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what are the keycode ids