/* HID KeyBoard Example
by: Jim Lindblom
date: 1/12/2012
license: MIT License - Feel free to use this code for any purpose.
No restrictions. Just keep this license if you go on to use this
code in your future endeavors! Reuse and share.
This is very simplistic code that allows you to send a 'z' with
a momentary pushbutton.
*/
#include <Keyboard.h>
int buttonPin = 9; // Set a button to any pin
void setup()
{
pinMode(buttonPin, INPUT); // Set the button as an input
digitalWrite(buttonPin, HIGH); // Pull the button high
Keyboard.begin(); //Init keyboard emulation
}
void loop()
{
if (digitalRead(buttonPin) == 0) // if the button goes low
{
Keyboard.write('z'); // send a 'z' to the computer via Keyboard HID
delay(1000); // delay so there aren't a kajillion z's
}
}
In this sketch,
connecting pin 9 to ground
will make the Qwiic Pro Micro spit out a '
z
' character. If you have a
simple,
momentary button
handy, tie one end to pin 9 and the other to ground. Otherwise, just use a wire to short
9 to GND.
After a
Keyboard.write()
or
Keyboard.print()
function has been performed by the Qwiic Pro Micro, your
computer will have to decide what to do with it. What your computer does with that character, or string of
characters, is entirely dependent on what program it's running at the time. If you have a text editor (Notepad,
Word, TextEdit, etc.) open and active, it'll print it out there. Or you can try using the textbox below to test.
SparkFun Qwiic Pro Micro USB C Test Area
Warning!
Any text written in this textbox will be erased when you refresh this webpage!
Example 2b: USB Mouse Functionality
SparkFun Electronics
Start Something!
SparkFun Qwiic Pro Micro USB C Testing Area