我開始使用具有以太網和電話的arduino的家庭自動化系統的基礎,該軟件與MIT應用程序發明者一起編程。我一直在玩代碼的教程,並得到了我的LED罰款從本地計算機使用互聯網使用瀏覽器和導航網址192.168.1.10/$1MIT App Inventor和Arduino以太網LED錯誤1109 URL無效
/* thrown together by Randy Sarafan
Allows you to turn on and off an LED by entering different urls.
To turn it on:
http://192.168.1.10/$1
To turn it off:
http://192.168.1.10/$2
Based almost entirely upon Web Server by Tom Igoe and David Mellis
Edit history:
created 18 Dec 2009
by David A. Mellis
modified 4 Sep 2010
by Tom Igoe
*/
#include <SPI.h>
#include <Ethernet.h>
boolean incoming = 0;
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDA, 0x02 };
//IPAddress ip(191,168,1,15); //<<< ENTER YOUR IP ADDRESS HERE!!! i commented this out and did it on the router side
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
void setup()
{
pinMode(8, OUTPUT);
// start the Ethernet connection and the server:
Ethernet.begin(mac);
server.begin();
Serial.begin(9600);
}
void loop()
{
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
//reads URL string from $ to first blank space
if(incoming && c == ' '){
incoming = 0;
}
if(c == '$'){
incoming = 1;
}
//Checks for the URL string $1 or $2
if(incoming == 1){
Serial.println(c);
if(c == '1'){
Serial.println("ON");
digitalWrite(8, HIGH);
}
if(c == '2'){
Serial.println("OFF");
digitalWrite(8, LOW);
}
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
}
}
這個問題我來打開和關閉有移動端的。我創建了麻省理工學院應用發明一個應用程序,應切換IP,而是給了我:
錯誤1109:指定的URL無效:192.168.1.10/$1
林很困惑。我知道這個URL是有效的,因爲我之前已經連接到它。有沒有辦法來重寫或修復它?
這裏是麻省理工學院應用發明AIA來源:http://www.filedropper.com/internetled
葡萄牙語版本的原因是什麼? – Tay2510 2015-04-02 05:27:25