前提・実現したいこと
昨日まで正常に動いていたプログラムが動かなくなりました
昨日からコードの改変はしていません。
発生している問題・エラーメッセージ
Arduino:1.8.13 (Windows Store 1.8.42.0) (Windows 10), ボード:"Arduino Uno" C:\Users\myama\Documents\Arduino\WebServer\WebServer.ino: In function 'void setup()': WebServer:17:9: error: expected unqualified-id before '.' token Server.begin(); //(7) ^ C:\Users\myama\Documents\Arduino\WebServer\WebServer.ino: In function 'void loop()': WebServer:21:10: error: expected unqualified-id before '=' token Client = Server.available(); //(8) ^ WebServer:23:13: error: expected primary-expression before ')' token if (Client) ^ WebServer:28:18: error: expected primary-expression before '.' token while (Client.connected()) //(9) ^ WebServer:30:17: error: expected primary-expression before '.' token if (Client.available()) //(10) ^ WebServer:32:24: error: expected primary-expression before '.' token char c = Client.read(); ^ WebServer:33:13: error: 'Request' was not declared in this scope if (Request.length() < 100) //(11) ^~~~~~~ WebServer:39:26: error: 'Request' was not declared in this scope Serial.println(Request); ^~~~~~~ WebServer:47:17: error: expected unqualified-id before '.' token Client.println("HTTP/1.1 200 OK"); //(17) ^ WebServer:48:17: error: expected unqualified-id before '.' token Client.println("Content-Type: text/html"); ^ WebServer:49:17: error: expected unqualified-id before '.' token Client.println("Connection: close"); //(18) ^ WebServer:50:17: error: expected unqualified-id before '.' token Client.println("Refresh: 2"); //(19) ^ WebServer:51:17: error: expected unqualified-id before '.' token Client.println(); //(20) ^ WebServer:52:17: error: expected unqualified-id before '.' token Client.println("<!DOCTYPE HTML>"); //(21) ^ WebServer:53:17: error: expected unqualified-id before '.' token Client.println("<html>"); ^ WebServer:54:17: error: expected unqualified-id before '.' token Client.println("<meta charset='utf-8'>"); ^ WebServer:55:17: error: expected unqualified-id before '.' token Client.println("アナログ値:"); ^ WebServer:56:17: error: expected unqualified-id before '.' token Client.println(analogRead(ANALOGPIN)); ^ WebServer:57:17: error: expected unqualified-id before '.' token Client.println("<br><br>"); ^ WebServer:58:17: error: expected unqualified-id before '.' token Client.println("<a href='?on'>LEDをONにする</a>"); ^ WebServer:59:17: error: expected unqualified-id before '.' token Client.println("<br><br>"); ^ WebServer:60:17: error: expected unqualified-id before '.' token Client.println("<a href='?off'>LEDをOFFにする</a>"); ^ WebServer:61:17: error: expected unqualified-id before '.' token Client.println("</html>"); ^ exit status 1 expected unqualified-id before '.' token 「ファイル」メニューの「環境設定」から 「より詳細な情報を表示する:コンパイル」を有効にすると より詳しい情報が表示されます。
該当のソースコード
#define LEDPIN 3 #define ANALOGPIN A0 #include "SPI.h" //(1) #include "Ethernet.h" byte MAC[] = {0x00, 0x08, 0xDC, 0x12, 0x34, 0x56}; //(2)7 void setup() { pinMode(LEDPIN, OUTPUT); Serial.begin(115200); //(4) delay(100); Serial.println("My IP-Adresse: "); Ethernet.begin(MAC); //(5) delay(3000); Serial.println(Ethernet.localIP()); //(6) Server.begin(); //(7) } void loop() { Client = Server.available(); //(8) if (Client) { Serial.println("New Client"); boolean blankLine = true; while (Client.connected()) //(9) { if (Client.available()) //(10) { char c = Client.read(); if (Request.length() < 100) //(11) Request += c; if (c == '\n' && blankLine) //(12)(13) { Serial.print("Request from Client: "); Serial.println(Request); if (Request.indexOf("on") > 0) //(14) digitalWrite(LEDPIN, HIGH); //(15) if (Request.indexOf("off") > 0) //(16) digitalWrite(LEDPIN, LOW); // HTTP Header 200 an den Browser schicken Client.println("HTTP/1.1 200 OK"); //(17) Client.println("Content-Type: text/html"); Client.println("Connection: close"); //(18) Client.println("Refresh: 2"); //(19) Client.println(); //(20) Client.println("<!DOCTYPE HTML>"); //(21) Client.println("<html>"); Client.println("<meta charset='utf-8'>"); Client.println("アナログ値:"); Client.println(analogRead(ANALOGPIN)); Client.println("<br><br>"); Client.println("<a href='?on'>LEDをONにする</a>"); Client.println("<br><br>"); Client.println("<a href='?off'>LEDをOFFにする</a>"); Client.println("</html>"); Request = ""; //(22) break; //(23) } if (c == '\n') //(24) blankLine = true; else if (c != '\r') blankLine = false; } } delay(1); //(25) Serial.println("client disconnected."); Serial.println(""); } Ethernet.maintain(); //(26) }
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。