// Include the required libraries
#include <WiFi.h>
// Define the pin for the IR sensor input
const int irSensorPin = 2; // Use the appropriate GPIO pin
// Define the pin for the LED
const int ledPin = 14; // Use the appropriate GPIO pin
// Wi-Fi credentials
const char* ssid = "Wokwi-GUEST";
const char* password = "";
void setup() {
// Initialize Serial communication
Serial.begin(115200);
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.print("connected to wifi");
// Set the IR sensor pin as input
pinMode(irSensorPin, INPUT);
// Set the LED pin as output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Read the value from the IR sensor
int irValue = digitalRead(irSensorPin);
if (irValue == HIGH) {
// Item detected, blink the LED
digitalWrite(ledPin, HIGH); // Turn on the LED
delay(500); // Wait for 500 milliseconds
digitalWrite(ledPin, LOW); // Turn off the LED
delay(500); // Wait for another 500 milliseconds
}else{
digitalWrite(ledPin, LOW); // Turn off the LED
}
}