Download examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino from Beifengdo/Arduino-Development: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/datasets/Beifengdo/Arduino-Development/resolve/c435f0563acdc531a9c292db74e71e978afbbe22/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino
- Command line
-
hf download hf://datasets/Beifengdo/Arduino-Development@c435f0563acdc531a9c292db74e71e978afbbe22/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino
-
curl -L -o KeyboardMessage.ino https://huggingface.co/datasets/Beifengdo/Arduino-Development/resolve/c435f0563acdc531a9c292db74e71e978afbbe22/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino
1.35 kB
| /* | |
| Keyboard Message test | |
| For the Arduino Leonardo and Micro. | |
| Sends a text string when a button is pressed. | |
| The circuit: | |
| - pushbutton attached from pin 4 to +5V | |
| - 10 kilohm resistor attached from pin 4 to ground | |
| created 24 Oct 2011 | |
| modified 27 Mar 2012 | |
| by Tom Igoe | |
| modified 11 Nov 2013 | |
| by Scott Fitzgerald | |
| This example code is in the public domain. | |
| https://www.arduino.cc/en/Tutorial/BuiltInExamples/KeyboardMessage | |
| */ | |
| 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; | |
| } | |