-
Notifications
You must be signed in to change notification settings - Fork 2
/
mouse_jiggler.ino
53 lines (47 loc) · 1.05 KB
/
mouse_jiggler.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"
#include "Mouse.h"
// To be more convincing, change the Arduino board name to something like a Logitech Mouse in the boards.txt file
// C:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt
int direction = 8;
void setup() {
delay(2000);
Serial.begin(9600);
Mouse.begin();
Keyboard.begin();
}
void loop() {
// put your main code here, to run repeatedly:
int rand_walk = random(0, 1000);
if (rand_walk < 993) {
if (direction == 0) {
Mouse.move(1, 0);
}
else if (direction == 1) {
Mouse.move(0, 1);
}
else if (direction == 2) {
Mouse.move(-1, 0);
}
else if (direction == 3) {
Mouse.move(0, -1);
}
else if (direction == 4) {
Mouse.move(1, 1);
}
else if (direction == 5) {
Mouse.move(-1, -1);
}
else if (direction == 6) {
Mouse.move(1, -1);
}
else if (direction == 7) {
Mouse.move(-1, 1);
}
else {
Mouse.move(0, 0);
}
}
else if (rand_walk < 1000) {
direction = random(0,20);
}
}