You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/05.pro-solutions/solutions-and-kits/edge-control/tutorials/user-manual/content.md
+56Lines changed: 56 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1006,8 +1006,64 @@ void loop() {
1006
1006
1007
1007
### Push Button
1008
1008
1009
+
The Enclosure Kit includes a push button so you can interact with the device in an easy way.
1009
1010
1011
+
To read the button state we can use the built-in functions of the Arduino programming language. We first need to define it as an input using the `POWER_ON` macro.
1012
+
1013
+
```cpp
1014
+
pinMode(POWER_ON, INPUT); // the push button is addressed to the MCU input as "POWER_ON"
1015
+
```
1016
+
1017
+
The state of the button can be read as usual with the `digitalRead(POWER_ON)` function.
1018
+
1019
+
***When the button is pressed, the input state gets low.***
1020
+
1021
+
In the example code below, we will attach the input to an interrupt and increase a counter with every tap shown in the LCD.
1022
+
1023
+
```cpp
1024
+
#include <Arduino_EdgeControl.h>
1025
+
1026
+
// Keep track of toggle-style press with an ISR
1027
+
volatile bool buttonPressed{ false };
1028
+
bool ledStatus{ false };
1029
+
1030
+
void setup() {
1031
+
1032
+
pinMode(POWER_ON, INPUT);
1033
+
// ISR for button press detection
1034
+
attachInterrupt(
1035
+
digitalPinToInterrupt(POWER_ON), [] {
1036
+
buttonPressed = true;
1037
+
},
1038
+
FALLING);
1039
+
1040
+
// set up the LCD's number of columns and rows:
1041
+
LCD.begin(16, 2);
1042
+
LCD.backlight();
1043
+
// Print a message to the LCD.
1044
+
LCD.home(); // go home
1045
+
LCD.print("Push Button");
1046
+
}
1047
+
1048
+
void loop() {
1049
+
static int counter = 0;
1050
+
if (buttonPressed == true) {
1051
+
buttonPressed = false;
1052
+
ledStatus = !ledStatus;
1053
+
LCD.setCursor(0, 1);
1054
+
LCD.print(counter++);
1055
+
}
1056
+
}
1057
+
```
1058
+

1010
1059
1011
1060
## RTC
1012
1061
1062
+
The built-in Real Time Clock of the Edge Control is ideal for timing irrigation processes and data logging.
1063
+
1064
+
***To maintain the RTC on time the included CR2032 coin cell must be used.***
0 commit comments