/**
* @file sketch.ino
* @brief Main entry point for the device using OOP design and multiple files.
*
* The device integrates an ultrasonic sensor, a relay module, and an LED.
* It detects proximity to open/close a valve and reports status periodically.
*
* Author: Your Name
* Version: 1.0
*/
#include <WiFi.h>
#include "Device.h"
// WiFi configuration
const char* ssid = "Wokwi-GUEST";
const char* password = "";
// Hardware pin configuration
const int trigPin = 25;
const int echoPin = 26;
const int relayPin = 17;
const int ledPin = 2;
// Threshold and reporting interval
const int distanceThreshold = 15; // Distance threshold in cm
const unsigned long reportInterval = 2000; // Reporting interval in ms
// Create the device components
UltrasonicSensor ultrasonicSensor(trigPin, echoPin);
Relay relay(relayPin);
LED led(ledPin);
// Create the main device instance
Device device(ultrasonicSensor, relay, led, distanceThreshold, reportInterval);
void setup() {
Serial.begin(115200);
// Start WiFi connection
// Initialize the device
device.begin();
}
void loop() {
// Update the device logic
device.update();
}