Keyestudio ESP32 Manual page 142

Starter kit
Hide thumbs Also See for ESP32:
Table of Contents

Advertisement

ESP32 Starter Kit
6. Knowledge Expansion
Let's make a rangefinder.
We display characters on LCD 1602. Program to show "Keyestudio" at (3,0) and "distance:" at (0,1) followed by the
distance value at (9,1).
When the value is smaller than 100(or 10), a residue of the third(or the second) bit still exists. Therefore, an "if"
judgement is necessary to determine a certain condition.
Wiring Diagram
Code
/*
keyestudio ESP32 Inventor Learning Kit
Project 25.2Ultrasonic Rangefinder
http://www.keyestudio.com
*/
#include
<Wire.h>
#include
<LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
line display
int
distance
=
0;
//Define a variable to receive the diatance value
int
EchoPin
=
14;
//Connect Echo pin to io14
138
//set the LCD address to 0x27 for a 16 chars and
2␣
(continues on next page)
Chapter 8. Arduino Tutorial

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Questions and answers

Related Products for Keyestudio ESP32

Table of Contents

Save PDF