EasyManua.ls Logo

Keyestudio ESP32 - 6. Knowledge Expansion

Keyestudio ESP32
344 pages
Print Icon
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...
ESP32 Starter Kit
6. Knowledge Expansion
Lets 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); //set the LCD address to 0x27 for a 16 chars and 2
˓line display
int distance = 0; //Define a variable to receive the diatance value
int EchoPin = 14; //Connect Echo pin to io14
(continues on next page)
138 Chapter 8. Arduino Tutorial

Table of Contents