#include <WiFi.h>
const char* ssid = "motorola edge 40 neo"; // Replace with your network SSID
const char* password = "1357924680"; // Replace with your network password
const char* server_ip = "192.168.220.131"; // IP address of the local server
const int buttonPin1 = 2; // Pin connected to the first push button
const int buttonPin2 = 4; // Pin connected to the second push button
WiFiClient client;
void setup() {
pinMode(buttonPin1, INPUT_PULLUP); // Set the first button pin as input with internal pull-up resistor
pinMode(buttonPin2, INPUT_PULLUP); // Set the second button pin as input with internal pull-up resistor
Serial.begin(115200);
// Connect to WiFi
WiFi.begin(ssid, password);
while (WiFi.status() !=WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
}
void loop() {
int buttonState1 = digitalRead(buttonPin1); // Read the state of the first push button
int buttonState2 = digitalRead(buttonPin2); // Read the state of the second push button
if (buttonState1 == LOW) { // First button is pressed
if (client.connect(server_ip, 80)) { // Connect to the local server
client.print("GET /push_button_data.php?button=1&state=pressed HTTP/1.1\r\n");
client.print("Host: ");
client.print(server_ip);
client.print("\r\n");
client.print("CEO is Busy");
client.print("Connection: close\r\n\r\n");
client.stop();
}
delay(1000); // Debounce delay
}
if (buttonState2 == LOW) { // Second button is pressed
if (client.connect(server_ip, 80)) { // Connect to the local server
client.print("GET /push_button_data.php?button=2&state=pressed HTTP/1.1\r\n");
client.print("Host: ");
client.print(server_ip);
client.print("\r\n");
client.print("CEO is Available");
client.print("Connection: close\r\n\r\n");
client.stop();
}
delay(1000); // Debounce delay
}
}