【问题标题】:MIT App Inventor and Arduino Ethernet LED Error 1109 URL not validMIT App Inventor 和 Arduino 以太网 LED 错误 1109 URL 无效
【发布时间】:2014-09-21 07:02:35
【问题描述】:

我正在使用带有以太网的 arduino 和带有我与 MIT App 发明者编程的软件的电话开始构建家庭自动化系统的基础。我一直在玩教程中的代码,并通过使用浏览器并导航 url 192.168.1.10/$1

让我的 LED 在本地计算机上使用互联网正常打开和关闭
/*  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 是有效的,因为我以前连接过它。有没有办法覆盖它或以其他方式修复它?

这是 MIT 应用程序发明者 AIA 来源:http://www.filedropper.com/internetled

【问题讨论】:

    标签: android arduino ethernet


    【解决方案1】:

    您应该在代码本身中指定 IP 地址。并更改“Ethernet.begin(mac);”到“Ethernet.begin(mac, ip);”。

    在使用 App Inventor 试用之前,您还应该尝试在浏览器中打开网页以检查其是否有效。

    【讨论】:

      【解决方案2】:

      在 AppInventor 错误“错误 1109:指定的 URL 无效:192.168.1.10/$1”中,您可能忘记在地址中输入“http://”。 例如,如果要将地址保存在全局变量或 tinyDB 中,则应输入 http://192.168.1.10/$1 这将是您连接 LED 的地址。

      【讨论】:

      • 葡萄牙语版本的原因是什么?
      • 我用谷歌翻译写的,我复制了翻译,但我也没有看到我复制了葡萄牙语,我只做了一个英文版,对不起
      猜你喜欢
      • 2017-04-11
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-21
      • 1970-01-01
      相关资源
      最近更新 更多