forked from kilianweigand/e-bikes-solartracker-gps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buttons.ino
38 lines (34 loc) · 1.14 KB
/
buttons.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
//PINDEFINITION
#define pinPanelHomeButton 9
#define pinAutomaticButton 10
#define pinPanelRightButton 11
#define pinPanelLeftButton 12
//VARIABLES
bool automaticButton = false;
bool panelLeftButton = false;
bool panelRightButton = false;
bool panelHomeButton = false;
void initButtons(){
pinMode(pinAutomaticButton, INPUT);
pinMode(pinPanelLeftButton, INPUT);
pinMode(pinPanelRightButton, INPUT);
pinMode(pinPanelHomeButton, INPUT);
updateButtons();
if (LOG_BUTTONS) Serial.println("initButtons done");
}
void updateButtons(){
//automatic on/off switch
automaticButton = digitalRead(pinAutomaticButton);
//directional switches left/right
panelLeftButton = digitalRead(pinPanelLeftButton);
panelRightButton = digitalRead(pinPanelRightButton);
//home switch
panelHomeButton = digitalRead(pinPanelHomeButton);
if (LOG_BUTTONS){
Serial.print("updateButtons -" );
Serial.print("automatic: "+ String(automaticButton));
Serial.print(" left: "+String(panelLeftButton));
Serial.print(" right: "+String(panelRightButton));
Serial.println(" home: "+String(panelHomeButton));
}
}