2016-05-13 144 views
0

這是我第一次在Stack Overflow上發佈,所以請原諒/指出我在格式化這個問題時已經違反的方式,下次我會盡量做得更好。我從我認爲是Yun的「Bridge」庫中運行HttpClient示例。相反,像它應該打印出ASCII的,它打印此:Arduino Yun HttpClient示例故障

<html> 
<head><title>301 Moved Permanently</title></head> 
<body bgcolor="white"> 
<center><h1>301 Moved Permanently</h1></center> 
<hr><center>nginx/1.4.2</center> 
</body> 
</html> 

這是正在運行的代碼:

#include <Bridge.h> 
#include <HttpClient.h> 

void setup() { 
    // Bridge takes about two seconds to start up 
    // it can be helpful to use the on-board LED 
    // as an indicator for when it has initialized 
    pinMode(13, OUTPUT); 
    digitalWrite(13, LOW); 
    Bridge.begin(); 
    digitalWrite(13, HIGH); 

    SerialUSB.begin(9600); 

    while (!SerialUSB); // wait for a serial connection 
} 

void loop() { 
    // Initialize the client library 
    HttpClient client; 

    // Make a HTTP request: 
    client.get("http://www.arduino.cc/asciilogo.txt"); 

    // if there are incoming bytes available 
    // from the server, read them and print them: 
    while (client.available()) { 
    char c = client.read(); 
    SerialUSB.print(c); 
    } 
    SerialUSB.flush(); 

    delay(5000); 
} 

我相信我的芸已正確連接到我的WiFi網絡,但我對於它如何工作或HTML如何處理知之甚少,所以任何形式的解釋都會有幫助。

謝謝!

回答

0

變化

client.get("http://www.arduino.cc/asciilogo.txt"); 

進入

client.get("http://arduino.cc/asciilogo.txt");