EasyManua.ls Logo

Keyestudio ESP32 - 3. Wiring Diagram; 4. Test Code

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
3. Wiring Diagram
4. Test Code
It is interesting that the played tones vary from distance of humans body.
/*
keyestudio ESP32 Inventor Learning Kit
Project 26 Human Body Piano
http://www.keyestudio.com
*/
int distance = 0; //Define a variable to receive the distance
int EchoPin = 14; //Connect Echo pin to io14
int TrigPin = 13; //Connect Trig pin to io13
int beeppin = 5;
float checkdistance() { //Acquire distance
// preserve a short low level to ensure a clear high pulse:
digitalWrite(TrigPin, LOW);
delayMicroseconds(2);
// Trigger the sensor by a high pulse of 10um or longer
digitalWrite(TrigPin, HIGH);
(continues on next page)
142 Chapter 8. Arduino Tutorial

Table of Contents