EasyManua.ls Logo

Freenove ESP32 - Page 91

Default Icon
159 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Need support? support@freenove.com
89
Chapter 7 Built-in Led
www.freenove.com
The following is the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "BuiltInLed.h"
void setup() {
setupBuiltInLed();
for (int i = 0; i < 5; i++) {
setBuiltInLed(HIGH);
delay(1000);
setBuiltInLed(LOW);
delay(1000);
}
}
void loop() {
task_showBuiltInLed(NULL);
}
Initializes the pins that control the onboard LEDs.
4
setupBuiltInLed();
Use the setBuiltInLed(bool) function to control the on-board LED to turn on or off.
The LED light on the control board turns on and off every 1 second, which repeats 5 times.
5
6
7
8
9
10
for (int i = 0; i < 5; i++) {
setBuiltInLed(HIGH);
delay(1000);
setBuiltInLed(LOW);
delay(1000);
}
BuiltInLed.h
1
2
3
4
5
6
7
8
9
10
11
#ifndef _BUILTINLED_h
#define _BUILTINLED_h
#include "Arduino.h"
#define LED_BUILT_IN 2
void setupBuiltInLed();
void setBuiltInLed(bool state);
void task_showBuiltInLed(void *pvParameters);
#endif

Related product manuals