Skip to content

Commit 6ad4b22

Browse files
committed
Add Blink Example for NANO ESP32
1 parent 3f807a8 commit 6ad4b22

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Blink for Arduino NANO ESP32 board
3+
*
4+
* This sketch can be used to generate an example binary that can be uploaded to ESP32 via OTA.
5+
* It needs to be used together with OTA.ino
6+
*
7+
* Steps to test OTA:
8+
* 1) Upload this sketch or any other sketch (this one this one lights up the RGB LED with different colours).
9+
* 2) In the IDE select: Sketch -> Export compiled Binary
10+
* 3) Upload the exported binary to a server
11+
* 4) Open the related OTA.ino sketch and eventually update the OTA_FILE_LOCATION
12+
* 5) Upload the sketch OTA.ino to perform OTA
13+
*/
14+
15+
void setLed(int blue, int gree, int red) {
16+
if (blue == 1) {
17+
digitalWrite(LED_BLUE, LOW);
18+
}
19+
else {
20+
digitalWrite(LED_BLUE, HIGH);
21+
}
22+
23+
if (gree == 1) {
24+
digitalWrite(LED_GREEN, LOW);
25+
}
26+
else {
27+
digitalWrite(LED_GREEN, HIGH);
28+
}
29+
30+
if (red == 1) {
31+
digitalWrite(LED_RED, LOW);
32+
}
33+
else {
34+
digitalWrite(LED_RED, HIGH);
35+
}
36+
}
37+
38+
39+
void setup()
40+
{
41+
pinMode(LED_BLUE, OUTPUT);
42+
pinMode(LED_GREEN, OUTPUT);
43+
pinMode(LED_RED, OUTPUT);
44+
}
45+
46+
void loop()
47+
{ // Blue LED on
48+
setLed(1, 0, 0);
49+
delay(1000);
50+
// Green LED on
51+
setLed(0, 1, 0);
52+
delay(1000);
53+
// Red LED on
54+
setLed(0, 0, 1);
55+
delay(1000);
56+
}

0 commit comments

Comments
 (0)