-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathmain.cpp
More file actions
35 lines (26 loc) · 664 Bytes
/
Copy pathmain.cpp
File metadata and controls
35 lines (26 loc) · 664 Bytes
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
#include <Arduino.h>
#include <ReactESP.h>
using namespace reactesp;
#define LED_PIN 2
int led_state = 0;
EventLoop event_loop;
void setup() {
Serial.begin(115200);
Serial.println("Starting");
pinMode(LED_PIN, OUTPUT);
Serial.println("Setting up timed events");
// toggle LED every 400 ms
event_loop.onRepeat(400, [] () {
led_state = !led_state;
digitalWrite(LED_PIN, led_state);
});
// Additionally, toggle LED every 1020 ms.
// This adds an irregularity to the LED blink pattern.
event_loop.onRepeat(1020, [] () {
led_state = !led_state;
digitalWrite(LED_PIN, led_state);
});
}
void loop() {
event_loop.tick();
}