EasyManua.ls Logo

Freenove ESP32 User Manual

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
Page #93 background imageLoading...
Page #93 background image
Need support? support@freenove.com
91
Chapter 7 Built-in Led
www.freenove.com
44
45
46
47
}
lastLedUpdateTime = millis();
}
}
Onboard LED initialization function.
10
11
12
void setupBuiltInLed(){
pinMode(LED_BUILT_IN, OUTPUT);
}
The function that controls the on-board LED to turn on or off.
14
15
16
void setBuiltInLed(bool state){
digitalWrite(LED_BUILT_IN, state);
}
Enter the if statement every occasionally. This usage has the same effect as the delay() function, but it will not
cause the code to be pause.
21
if (millis() - lastLedUpdateTime > intervalTime){
Control the LED's on and off states by shifting a variable, sqValue, and taking the least significant bit as the
control signal.
If the current state of the LED is different from the previous state, control the LED to change its current state
and update the previous state to the current state.
24
25
26
27
28
29
ledStatus = ((sqValue >> bitIndex) & 0x01) ? true : false;
if (ledStatus != lastLedStatus){
digitalWrite(LED_BUILT_IN, (uint8_t)ledStatus);
lastLedStatus = ledStatus;
bitDiff++;
}
Introducing a variable called bitIndex to control the shift amount, so as to change the number of shifts
performed on sqValue each time,. If the number of shifts exceeds 9, the next time entering the if condition
will be delayed by 600ms, and sqValue starts shifting from the 0th bit again.
30
31
32
33
34
35
36
bitIndex++;
if (bitIndex >= 10){
intervalTime = 600;
ledRunnigStatus = 1;
bitDiff = 0;
bitIndex = 0;
}
If the previous shift cycle is completed, set the time for entering the if condition to 100ms each time and
proceed to the next shift cycle.
38
39
40
41
case 1: // off
intervalTime = 100;
ledRunnigStatus = 0;
break;
Question and Answer IconNeed help?

Do you have a question about the Freenove ESP32 and is the answer not in the manual?

Freenove ESP32 Specifications

General IconGeneral
Clock Speed240 MHz
RAM520 KB SRAM
Wi-Fi802.11 b/g/n
UART3
Operating Voltage3.3V
Input Voltage5V
DC Current per I/O Pin40mA
USBMicro USB
MicrocontrollerESP32
ChipESP32
BluetoothBluetooth v4.2 BR/EDR and BLE standard
ADC Channels/Analog Input Pins18
I2CYes
SPIYes
InterfacesI2C, SPI, UART
CPUDual-Core 32-bit LX6 Microprocessor

Summary

Safety and Precautions

General Safety Guidelines

Outlines crucial safety measures for handling and using the robot kit to prevent injury or damage.

Hardware Components

ESP32 Expansion Board and Modules

Details the ESP32 expansion board, ESP32 module, camera, and other electronic components.

Mechanical Parts and Tools

Lists acrylic parts, servos, screws, nuts, standoffs, and necessary tools for assembly.

Software and Firmware Setup

CH340 Driver and Firmware Installation

Guides on installing the CH340 driver and burning firmware for OS.

Freenove App and Arduino IDE Setup

Covers installing the Freenove app and setting up the Arduino IDE environment.

ESP32 Pin Configuration

Details ESP32 pins, their functions, and descriptions for robot connectivity.

Robot Assembly and Calibration

Step-by-Step Assembly Guide

Details the process of assembling the robot's body, legs, head, and wiring.

Servo Wiring and Calibration

Guides on connecting ESP32, batteries, servos, and performing robot calibration.

Robot Functionality and Control

Freenove App Features

Overviews app features like Wi-Fi config, LED control, and interaction.

Ultrasonic Ranging and Motion Control

Explains ultrasonic sensor and provides code for robot movements.

Communication Protocols and Commands

Explains communication commands via Serial, BLE, Wi-Fi, and development aspects.

Related product manuals