-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimquitter.ino
37 lines (34 loc) · 1.03 KB
/
vimquitter.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
#include <CapacitiveSensor.h>
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
// pin 2 -> 1K resistor -> foil on cap
// pin 4 -> 4.7M resistor to foil on cap
// A9 pin to LED (add ~200ohm resistor) which will turn on when triggered
void setup()
{
pinMode(12, OUTPUT);
}
void loop()
{
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);
// also tested with 1400 on bigger foil
if (total1 > 250) {
digitalWrite(12, HIGH);
Keyboard.set_key1(KEY_ESC);
Keyboard.send_now();
delay(1);
Keyboard.set_key1(0);
Keyboard.send_now();
Keyboard.print(":q!");
delay(1);
Keyboard.send_now();
Keyboard.set_key2(KEY_ENTER);
Keyboard.send_now();
delay(1);
Keyboard.set_key2(0);
Keyboard.send_now();
delay(500);
digitalWrite(12, LOW);
}
delay(5);
}