-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmacro.ino
72 lines (59 loc) · 1.38 KB
/
macro.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "Keyboard.h"
#include "Mouse.h"
const int button1Pin = 4;
const int button2Pin = 5;
const int button3Pin = 6;
boolean button1PrevState = LOW;
boolean button2PrevState = LOW;
boolean button3PrevState = LOW;
boolean button1State = LOW;
boolean button2State = LOW;
boolean button3State = LOW;
char ctrlKey = KEY_LEFT_CTRL;
void setup() {
delay(4000);
Serial.begin(9600);
Mouse.begin();
Keyboard.begin();
pinMode(button1Pin, INPUT_PULLUP);
pinMode(button2Pin, INPUT_PULLUP);
pinMode(button3Pin, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
button1State = digitalRead(button1Pin);
button2State = digitalRead(button2Pin);
button3State = digitalRead(button3Pin);
if (button1State == HIGH && button1PrevState == LOW)
{
button1PrevState = HIGH;
Mouse.move(-400, 0);
delay(1000);
}
else if (button1State == LOW)
{
button1PrevState = LOW;
}
if (button2State == HIGH && button2PrevState == LOW)
{
button2PrevState = HIGH;
Mouse.move(400, 0);
delay(1000);
}
else if (button2State == LOW)
{
button2PrevState = LOW;
}
if (button3State == HIGH && button3PrevState == LOW)
{
button3PrevState = HIGH;
Keyboard.press(ctrlKey);
Keyboard.press('v');
Keyboard.releaseAll();
delay(1000);
}
else if (button3State == LOW)
{
button3PrevState = LOW;
}
}