Skip to content

Commit a2ed538

Browse files
authored
User friendliness
Step 1) Adding control system (pin and if statement).
1 parent 8282c8b commit a2ed538

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed
Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1+
/**************************************************************
2+
** Brief introduction to a few HID Keyboard commands. **
3+
** Unlike the other Keyboard library, this one doesn't use **
4+
** the "press", "release", and "send" commands. **
5+
**************************************************************/
6+
17
#include "PluggableUSBHID.h"
28
#include "USBKeyboard.h"
39

410
USBKeyboard Keyboard;
511

6-
void setup() {
7-
// put your setup code here, to run once:
12+
// Arbitrary pin.
13+
const int CONTROL_PIN = 2;
814

15+
void setup() {
16+
// We will use this to start/end the prints.
17+
pinMode(CONTROL_PIN, INPUT_PULLUP);
918
}
1019

1120
void loop() {
12-
// put your main code here, to run repeatedly:
13-
delay(1000);
14-
Keyboard.printf("Hello world\n\r");
21+
// This will run only if the control pin is connected to ground.
22+
if( digitalRead(CONTROL_PIN) == LOW){
23+
delay(1000);
24+
Keyboard.printf("Hello world\n\r");
25+
}
1526
}

0 commit comments

Comments
 (0)