-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathHID_EXAMPLE.ino
53 lines (43 loc) · 1.8 KB
/
HID_EXAMPLE.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <Keyboard.h> //Including the keyboard library
#include <Mouse.h> //Including the mouse library
int pinA = 2; //Declaring variables for the pins
int pinB = 3;
int pinC = 4;
int pinD = 5;
int pinE = 6;
void setup() {
pinMode(pinA, INPUT_PULLUP); //Setting up the internal pull-ups resistors
pinMode(pinB, INPUT_PULLUP); //and also setting the pins to inputs.
pinMode(pinC, INPUT_PULLUP);
pinMode(pinD, INPUT_PULLUP);
pinMode(pinE, INPUT_PULLUP);
}
void loop() {
if (digitalRead(pinA) == LOW) //Checking if the first switch has been pressed
{
Keyboard.write('A'); //Sending the "A" character
delay(500);
}
if (digitalRead(pinB) == LOW) //Checking if the second switch has been pressed
{
Keyboard.print("You pressed switch B"); //Sending a string
delay(500);
}
if (digitalRead(pinC) == LOW) //Checking if the third switch has been pressed
{
Keyboard.println("You have pressed switch C."); //Sending a string and a return
delay(500);
}
if (digitalRead(pinD) == LOW) //Checking if the fourth switch has been pressed
{
Mouse.press(MOUSE_RIGHT); //Pressing down the right click
delay(100);
Mouse.release(MOUSE_RIGHT); //Releasing the right click
delay(500);
}
if (digitalRead(pinE) == LOW) //Checking if the fifth switch has been pressed
{
Keyboard.println("Subscribe to Simple Electronics!");
delay(500); //Sending a string and a return
}
}