2014-09-21 103 views
0

我開始使用具有以太網和電話的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

回答

-1

葡萄牙語: 沒有埃羅做appinventor 「錯誤1109:指定的URL無效:192.168.1.10/$1」 VOCE頗得之三esquecido德colocar o「的HTTP ://「do seuendereço。 示例,se voce esta guardando oendereçoem uma variablevel global or any tinyDB,voce deve colocar http://192.168.1.10/ $ 1 Este serio o seuendereçopara ligar o led。

English: 在AppInventor錯誤「錯誤1109:指定的URL無效:192.168.1.10/$1」您可能忘記將「http://」放在您的地址中。 例如,如果要將地址保存在全局變量或tinyDB中,則應該將http://192.168.1.10/ $ 1 這將是您連接led的地址。

+0

葡萄牙語版本的原因是什麼? – Tay2510 2015-04-02 05:27:25

0

您應該在代碼本身指定IP地址。並更改「Ethernet.begin(mac);」到「Ethernet.begin(mac,ip);」。

在使用App Inventor進行嘗試之前,您還應該嘗試在瀏覽器中打開網頁以檢查它是否有效。

相關問題