-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbutton.ino
48 lines (39 loc) · 1.24 KB
/
button.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
/**
Created by Dor Cohen.
IG account: @do.robotics
3D Model: https://www.thingiverse.com/thing:5400168
*/
#include <TrinketHidCombo.h>
const int buttonPin = 0;
bool pressed = false;
void setup() {
pinMode(buttonPin, INPUT);
TrinketHidCombo.begin();
}
void loop() {
int buttonState = digitalRead(buttonPin);
if (buttonState == HIGH && !pressed) {
TrinketHidCombo.pressKey(0, KEYCODE_ENTER);
TrinketHidCombo.pressKey(0, 0); // key release
pressed = true;
delay(100);
} else {
TrinketHidCombo.poll();
if (buttonState == LOW) pressed = false;
}
}
/*
* See keycode here:
* https://github.com/adafruit/Adafruit-Trinket-USB/blob/master/TrinketHidCombo/TrinketHidCombo.h
* https://github.com/adafruit/Adafruit-Trinket-USB/blob/master/TrinketHidCombo/TrinketHidCombo.cpp (special keycodes)
*/
/*
* Some other useful stuff
* TrinketHidCombo.pressKey(KEYCODE_MOD_LEFT_ALT, KEYCODE_F4);
* TrinketHidCombo.pressMultimediaKey(MMKEY_VOL_UP);
*/
/* Useful links:
* Tutorial: https://www.instructables.com/DIGIKEYPAD-DigiSpark/
* Drivers & Setup: https://www.youtube.com/watch?v=MmDBvgrYGZs&list=LL&index=1
* Library: https://github.com/adafruit/Adafruit-Trinket-USB/tree/master/TrinketHidCombo
*/