message
message
h>
#include <Servo.h>
#include <DHT.h>
#include <ESP32WebServer.h>
// WiFi credentials
#define WIFI_SSID "your_ssid"
#define WIFI_PASSWORD "your_password"
// Pin definitions
#define SMOKE_SENSOR_PIN 34 // Smoke sensor
#define TEMP_SENSOR_PIN 32 // DHT22 or DHT11 sensor for temperature
#define WATER_PUMP_PIN 33 // Relay or transistor for controlling the water
pump
#define YAW_SERVO_PIN 10
#define PITCH_SERVO_PIN 11
#define ROLL_SERVO_PIN 12
// Define servos
Servo yawServo;
Servo pitchServo;
Servo rollServo;
class TurretControl {
public:
TurretControl() {
// Initialize servos
yawServo.attach(YAW_SERVO_PIN);
pitchServo.attach(PITCH_SERVO_PIN);
rollServo.attach(ROLL_SERVO_PIN);
void handleMove() {
String direction = webServer.arg("direction");
if (direction == "up") {
upMove(1);
} else if (direction == "down") {
downMove(1);
} else if (direction == "left") {
leftMove(1);
} else if (direction == "right") {
rightMove(1);
} else if (direction == "fire") {
fireWater();
}
TurretControl turret;
void setup() {
Serial.begin(9600);
// Connect to Wi-Fi
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi!");
void loop() {
webServer.handleClient(); // Handle web requests from the mobile app