/* ESP32 WiFi Scanning example */
#include "WiFi.h"
const int inputPin1 = 32;
const int inputPin2 = 33;
const int inputPin3 = 26;
const int inputPin4 = 27;
const int inputPin5 = 14;
const int inputPin6 = 12;
const int inputPin7 = 13;
const int inputPin8 = 15;
const int inputPin9 = 18;
const int inputPin10 = 19;
const int inputPins[] = {32, 33, 26, 27, 14, 12, 13, 15, 18, 19};
const int numInputPins = sizeof(inputPins) / sizeof(inputPins[0]);
int pinStatus[numInputPins] = {0}; // Array to store pin status
void setup() {
pinMode(inputPin1, INPUT_PULLDOWN);
pinMode(inputPin2, INPUT_PULLDOWN);
pinMode(inputPin3, INPUT_PULLDOWN);
pinMode(inputPin4, INPUT_PULLDOWN);
pinMode(inputPin5, INPUT_PULLDOWN);
pinMode(inputPin6, INPUT_PULLDOWN);
pinMode(inputPin7, INPUT_PULLDOWN);
pinMode(inputPin8, INPUT_PULLDOWN);
pinMode(inputPin9, INPUT_PULLDOWN);
pinMode(inputPin10, INPUT_PULLDOWN);
Serial.begin(115200);
}
void loop() {
// Check each input pin
for (int i = 0; i < numInputPins; i++) {
int currentStatus = digitalRead(inputPins[i]);
// If pin status has changed from LOW to HIGH
if (currentStatus == HIGH && pinStatus[i] == LOW) {
// Print the pin number
Serial.print("Pin ");
Serial.print(inputPins[i]);
Serial.println(" turned ON.");
}
// Update the pin status
pinStatus[i] = currentStatus;
}
// Add a small delay to avoid excessive processing
delay(100);
}