/*
* This ESP32 code is created by esp32io.com
*
* This ESP32 code is released in the public domain
*
* For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-controls-fan
*/
#define RELAY_PIN 13 // ESP32 pin GIOP13, which connects to the IN pin of relay
// the code in setup function runs only one time when ESP32 starts
void setup() {
// initialize digital pin A5 as an output.
pinMode(RELAY_PIN, OUTPUT);
}
// the code in loop function is executed repeatedly infinitely
void loop() {
digitalWrite(RELAY_PIN, HIGH); // turn on fan 10 seconds
delay(10000);
digitalWrite(RELAY_PIN, LOW); // turn off fan 10 seconds
delay(5000);
}