Im trying to make an iron man helmet with JARVIS that will respond and execute commands. im using arduino(for the servos etc.) and python(for jarvis). Right now im setting up my new esp8266 with wifi so its all wireless. at the moment im only focusing on the arduino code, and it isnt working as expected. I'm mainly using chatgpt for the code because im not a master at coding. Any help would be appreciated! My code: #include
<ESP8266WiFi.h>
#include <Servo.h>
// Replace with your network credentials
const char* ssid = "my_ssid";
const char* password = "my_password";
WiFiServer server(80);
Servo myServo;
const int ledPin = 13;
String command = "";
void setup() {
Serial.begin(115200);
Serial.println("Starting setup...");
myServo.attach(9);
pinMode(ledPin, OUTPUT);
// Connect to Wi-Fi
WiFi.begin(ssid, password);
Serial.print("Connecting to Wi-Fi");
int attempts = 0;
while (WiFi.status() != WL_CONNECTED && attempts < 20) {
delay(1000);
Serial.print(".");
attempts++;
}
if (WiFi.status() == WL_CONNECTED) {
Serial.println("\nConnected to Wi-Fi");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP()); // Print ESP8266 IP Address
} else {
Serial.println("\nFailed to connect to Wi-Fi");
}
// Start the server
server.begin();
Serial.println("Server started");
}
void loop() {
WiFiClient client = server.available(); // Listen for incoming clients
if (client) {
Serial.println("New client connected");
String request = client.readStringUntil('\r'); // Read client request
client.flush();
Serial.print("Request: ");
Serial.println(request);
// Parse the command from the request
if (request.indexOf("/S") != -1) {
Serial.println("Command S received");
myServo.write(90);
delay(50); // Reduce delay time for quicker response
myServo.write(0);
command = "S";
}
else if (request.indexOf("/L1") != -1) {
Serial.println("Command L1 received");
digitalWrite(ledPin, HIGH);
command = "L1";
}
else if (request.indexOf("/L0") != -1) {
Serial.println("Command L0 received");
digitalWrite(ledPin, LOW);
command = "L0";
}
else if (request.indexOf("/P") != -1) {
Serial.println("Command P received");
digitalWrite(ledPin, LOW);
command = "P";
client.stop(); // Disconnect client
while (true); // Halt the system
}
// Respond to the client
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("<h1>Command received: " + command + "</h1>");
client.println("</html>");
client.stop(); // Close the connection
Serial.println("Client disconnected");
}
}
the error code i keep getting: . Variables and constants in RAM (global, static), used 28200 / 80192 bytes (35%)
║ SEGMENT BYTES DESCRIPTION
╠══ DATA 1504 initialized variables
╠══ RODATA 992 constants
╚══ BSS 25704 zeroed variables
. Instruction RAM (IRAM_ATTR, ICACHE_RAM_ATTR), used 59747 / 65536 bytes (91%)
║ SEGMENT BYTES DESCRIPTION
╠══ ICACHE 32768 reserved space for flash instruction cache
╚══ IRAM 26979 code in IRAM
. Code in flash (default, ICACHE_FLASH_ATTR), used 238784 / 1048576 bytes (22%)
║ SEGMENT BYTES DESCRIPTION
╚══ IROM 238784 code in flash
esptool.py v3.0
Serial port /dev/cu.usbserial-0001
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 48:3f:da:89:b3:27
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0340
Compressed 272416 bytes to 200371...
Writing at 0x00000000... (7 %)
Writing at 0x00004000... (15 %)
Writing at 0x00008000... (23 %)
Writing at 0x0000c000... (30 %)
Writing at 0x00010000... (38 %)
Writing at 0x00014000... (46 %)
Writing at 0x00018000... (53 %)
Writing at 0x0001c000... (61 %)
Writing at 0x00020000... (69 %)
Writing at 0x00024000... (76 %)
Writing at 0x00028000... (84 %)
Writing at 0x0002c000... (92 %)
Writing at 0x00030000... (100 %)
Wrote 272416 bytes (200371 compressed) at 0x00000000 in 17.7 seconds (effective 123.1 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...