Skip to content

Commit a204411

Browse files
committed
User Manual writing commit 14
1 parent 9b00ef0 commit a204411

File tree

2 files changed

+56
-0
lines changed
  • content/hardware/05.pro-solutions/solutions-and-kits/edge-control/tutorials/user-manual

2 files changed

+56
-0
lines changed
1.86 MB
Loading

content/hardware/05.pro-solutions/solutions-and-kits/edge-control/tutorials/user-manual/content.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,8 +1006,64 @@ void loop() {
10061006

10071007
### Push Button
10081008

1009+
The Enclosure Kit includes a push button so you can interact with the device in an easy way.
10091010

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+
![LCD and Push Button demo running the code from above](assets/LCD-PB.png)
10101059

10111060
## RTC
10121061

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.***
1065+
1066+
`getRTDateTime(); // 2023-09-30 16:33:19 `
1067+
`getRTCTime(); // 16:33:19`
1068+
`getRTCDate(); // 2023-09-30`
10131069
## Communication

0 commit comments

Comments
 (0)