-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbutton_driver.ino
More file actions
executable file
·47 lines (45 loc) · 1.39 KB
/
button_driver.ino
File metadata and controls
executable file
·47 lines (45 loc) · 1.39 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
42
43
44
45
46
47
/************************* button io *************************/
#define BUTTON_A 47
#define BUTTON_B 49
#define BUTTON_C 12
#define BUTTON_D 11
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.print( "button test\r\n" );
pinMode(BUTTON_A,INPUT_PULLUP);
pinMode(BUTTON_B,INPUT_PULLUP);
pinMode(BUTTON_C,INPUT_PULLUP);
pinMode(BUTTON_D,INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(BUTTON_A) == LOW){
delay(10); // <! delay
if(digitalRead(BUTTON_A) == LOW){
while(digitalRead(BUTTON_A) == LOW);
Serial.print("button a\r\n");
}
}
if(digitalRead(BUTTON_B) == LOW){
delay(10); // <! delay
if(digitalRead(BUTTON_B) == LOW){
while(digitalRead(BUTTON_B) == LOW);
Serial.print("button b\r\n");
}
}
if(digitalRead(BUTTON_C) == LOW){
delay(10); // <! delay
if(digitalRead(BUTTON_C) == LOW){
while(digitalRead(BUTTON_C) == LOW);
Serial.print("button c\r\n");
}
}
if(digitalRead(BUTTON_D) == LOW){
delay(10); // <! delay
if(digitalRead(BUTTON_D) == LOW){
while(digitalRead(BUTTON_D) == LOW);
Serial.print("button d\r\n");
}
}
}