Keyestudio ESP32 Manual page 110

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

Advertisement

ESP32 Starter Kit
3. Wiring Diagram
4. Test Code
From the working principle, we can read the level of the sensor pin to judge whether there are people nearby.
/*
keyestudio ESP32 Inventor Learning Kit
Project 17.1 Invasion Alarm
http://www.keyestudio.com
*/
int
pir
=
5;
//Define IO5 as PIR sensor pin
void
setup() {
pinMode(pir,INPUT);
Serial.begin(9600);
}
void
loop() {
int
pir_val
=
digitalRead(pir);
Serial.print("pir_val:");
Serial.println(pir_val);
delay(500);
106
//Set IO5 pin to input
//Read the PIR result and assign it to pir_val
//Print "pir_val"
(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