-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.cpp
More file actions
41 lines (39 loc) · 1.14 KB
/
code.cpp
File metadata and controls
41 lines (39 loc) · 1.14 KB
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
#include "Keyboard.h"
#define button1 10
#define button2 8
#define button3 7
#define button4 9
boolean b1_pressed, b2_pressed, b3_pressed, b4_pressed = false;
void setup() {
Serial.begin(9600);
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
pinMode(button3, INPUT_PULLUP);
pinMode(button4, INPUT_PULLUP);
}
void loop() {
if (digitalRead(button1) == 0 && b1_pressed == false) {
Keyboard.print("Stay ");
b1_pressed = true;
} else if (digitalRead(button1) == 1 && b1_pressed == true) {
b1_pressed = false;
}
if (digitalRead(button2) == 0 && b2_pressed == false) {
Keyboard.print("tuned ");
b2_pressed = true;
}else if (digitalRead(button2) == 1 && b1_pressed == true) {
b2_pressed = false;
}
if (digitalRead(button3) == 0 && b3_pressed == false) {
Keyboard.print("for ");
b3_pressed = true;
}else if (digitalRead(button3) == 1 && b3_pressed == true) {
b3_pressed = false;
}
if (digitalRead(button4) == 0 && b4_pressed == false) {
Keyboard.print("more videos!");
b4_pressed = true;
}else if (digitalRead(button4) == 1 && b4_pressed == true) {
b4_pressed = false;
}
}