電子工程系應 用 電 子 組 電 腦 遊 戲 設 計 組 使用HttpClient 吳錫修 November 20, 2015
shapethefuture 電子工程系 應 用 電 子 組 電 腦 遊 戲 設 計 組  範例:File/Examples/Bridge/HTTPClient  HTTPClient範例展示Arduino Yún透過HTTP協定由網站下載資料  測試網頁 http://arduino.cc/asciilogo.txt  參考資料 http://www.arduino.cc/en/Tutorial/HttpClient HTTPClient範例 2
shapethefuture 電子工程系 應 用 電 子 組 電 腦 遊 戲 設 計 組  Arduino Yún與電腦連接到相同WiFi  確認已連接Arduino Yún 測試HTTPClient範例 1/2 3
shapethefuture 電子工程系 應 用 電 子 組 電 腦 遊 戲 設 計 組  開啟Arduino Yún Console視窗 Tools/Serial Monitor 測試HTTPClient範例 2/2 4
shapethefuture 電子工程系 應 用 電 子 組 電 腦 遊 戲 設 計 組 #include <Bridge.h> #include <HttpClient.h> void setup() { pinMode(13, OUTPUT); digitalWrite(13, LOW); Bridge.begin(); //起始Bridge digitalWrite(13, HIGH); //指示Bridge已啟動 Console.begin(); //啟動Console while (!Console); //等待Console連線 } 解析HTTPClient範例程式碼 1/2 5
shapethefuture 電子工程系 應 用 電 子 組 電 腦 遊 戲 設 計 組 void loop() { HttpClient client; //初始化HttpClient //送出HTTP連線請求 client.get("http://arduino.cc/asciilogo.txt"); while (client.available()) { //檢查是否有回應資料 char c = client.read(); //讀取HTTP連線回傳資料 Console.print(c); } Console.flush(); //等待資料輸出完畢 delay(10000); //間隔10秒再重複作業 } 解析HTTPClient範例程式碼 2/2 6

Arduino Yún使用Http client

  • 1.
    電子工程系應 用 電子 組 電 腦 遊 戲 設 計 組 使用HttpClient 吳錫修 November 20, 2015
  • 2.
    shapethefuture 電子工程系 應 用 電子 組 電 腦 遊 戲 設 計 組  範例:File/Examples/Bridge/HTTPClient  HTTPClient範例展示Arduino Yún透過HTTP協定由網站下載資料  測試網頁 http://arduino.cc/asciilogo.txt  參考資料 http://www.arduino.cc/en/Tutorial/HttpClient HTTPClient範例 2
  • 3.
    shapethefuture 電子工程系 應 用 電子 組 電 腦 遊 戲 設 計 組  Arduino Yún與電腦連接到相同WiFi  確認已連接Arduino Yún 測試HTTPClient範例 1/2 3
  • 4.
    shapethefuture 電子工程系 應 用 電子 組 電 腦 遊 戲 設 計 組  開啟Arduino Yún Console視窗 Tools/Serial Monitor 測試HTTPClient範例 2/2 4
  • 5.
    shapethefuture 電子工程系 應 用 電子 組 電 腦 遊 戲 設 計 組 #include <Bridge.h> #include <HttpClient.h> void setup() { pinMode(13, OUTPUT); digitalWrite(13, LOW); Bridge.begin(); //起始Bridge digitalWrite(13, HIGH); //指示Bridge已啟動 Console.begin(); //啟動Console while (!Console); //等待Console連線 } 解析HTTPClient範例程式碼 1/2 5
  • 6.
    shapethefuture 電子工程系 應 用 電子 組 電 腦 遊 戲 設 計 組 void loop() { HttpClient client; //初始化HttpClient //送出HTTP連線請求 client.get("http://arduino.cc/asciilogo.txt"); while (client.available()) { //檢查是否有回應資料 char c = client.read(); //讀取HTTP連線回傳資料 Console.print(c); } Console.flush(); //等待資料輸出完畢 delay(10000); //間隔10秒再重複作業 } 解析HTTPClient範例程式碼 2/2 6