Skip to content

Instantly share code, notes, and snippets.

@mitchtech
Created June 3, 2012 22:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mitchtech/2865205 to your computer and use it in GitHub Desktop.
Save mitchtech/2865205 to your computer and use it in GitHub Desktop.
/* 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
}
@scapegoat01
Copy link

what are the keycode ids

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment