相信不少朋友已經在玩 Arduino了,並且通常都是使用官方的Arduino IDE來寫程序控制Arduino硬件。爲了可以實現更加方便的控制,微軟在Windows IoT計劃中推出了Windows Remote Arduino。簡單來講,Windows Remote Arduino是一個開源的Windows運行時組件,經過它,咱們可使用藍牙、USB、WiFi或者是以太網這四種鏈接方式中的任意一種來控制Arduino硬件。所以,在Windows 10這個統一的大平臺下,咱們可使用Windows 10系統的PC、平板、手機,甚至是樹莓派等運行IoT Core的設備來控制Arduino硬件。Windows Remote Arduino提供的功能包括:html
(1)GPIO控制(模擬和數字)git
Digital Writegithub
Digital Readapp
Analog Writepost
Analog Readui
Setting the pin mode for any pinurl
Receive events when values change / are reported.spa
(2)I2C接口通訊3d
(3)Firmata用戶自定義協議htm
這裏將運行Windows的PC、Surface、或者Windows Phone統稱爲上位機,咱們可使用如下三種方法中的任意一種來完成上位機的環境設置:
上述三種方式的難以程度依次升高。其中,第一種適用於簡單的使用場景,用戶無需編寫代碼就能夠經過下載的Windows Remote Arduino Experience來完成Arduino設備的控制。第二種適用於編寫本身的UWP應用場景,經過引用Windows Remote Arduino包,在本身編寫的程序中完成Arduino設備的控制。第三種須要手動將Windows Remote Arduino源代碼工程添加到本身的工程中來,這種方式能夠得到的自由度最大,用戶能夠根據本身的需求定製Windows Remote Arduino。
這裏,以第一種方法爲例,打開微軟商店,直接在PC或者Mobile上安裝Windows Remote Arduino Experience應用,該應用是UWP應用。
Windows Remote Arduino創建在Firmata protocol 基礎之上,所以,咱們首先須要在Arduino硬件設備上燒寫對應的代碼。在安裝Arduino IDE的時候,StandardFirmata 是默認安裝的,用戶能夠按照如下的步驟進行程序的燒寫:
若是用戶僅僅但願經過USB來控制Arduino設備的話,到這裏已經完成了Arduino的設置工做。若是用戶但願經過藍牙來控制Arduino設備,那麼,首先,PC上須要有藍牙模塊,其次,Ardunio上也須要鏈接一個藍牙模塊,具體能夠參考這個文章《hook up a Bluetooth device to the Arduino 》。另外,若是用戶但願經過WiFi來控制Arduino設備,那麼,Arduino須要一個WiFi Shield,具體能夠參考這個文章《hook up a Wi-Fi device to the Arduino 》。
打開Windows Remote Arduino Experience應用程序,鏈接類型選擇USB,速率選擇57600。若是此時Arduino已經正確鏈接了PC的USB接口,則會自動顯示Arduino Uno(COM*),用戶只需點擊Connect就能夠鏈接Arduino設備了,以下圖所示,
以後,應用程序界面分別包含了Digital、 Analog、PWM這三個頁面,用戶能夠點擊對應的頁面進行遠程控制和數據讀取。以Pin 13爲例,默認是Output的Low,經過點擊更改電平,以下圖所示。
觀察Arduino Uno的板載Pin 13鏈接的LED燈,便可發現其狀態已經點亮,以下圖所示。
筆者手頭有W5100的Ethernet Shield,因此嘗試了這種方式。注意,這種方式下,咱們須要從新燒寫Arduino的sketch。具體步驟以下:
燒寫完成之後,能夠將W5100 Ethernet Shield經過網線鏈接到TPLink上,查看其自動得到的IP地址,固然,用戶也能夠修改standard-firmata-ethernet.ino的代碼,設置其IP地址。
而後,在PC或者Mobile上打開Windows Remote Arduino Experience應用程序,鏈接類型選擇Network
,速率選擇57600。IP地址處填寫Arduino得到的IP地址,端口號默認爲5000(也能夠經過standard-firmata-ethernet.ino進行修改)。
點擊鏈接以後,一樣能夠按照上面第4節的內容控制Arduino了。
參考連接:
1. http://ms-iot.github.io/content/en-US/win10/WRA.htm
2. Download the Windows Remote Arduino Experience app from the Microsoft Store
4. Manually add the Windows Remote Arduino project files to a new Visual Studio solution
5. hook up a Bluetooth device to the Arduino
6. hook up a Wi-Fi device to the Arduino
7. https://github.com/ms-iot/remote-wiring/
8. https://github.com/ms-iot/remote-wiring/#notes-on-wifi-and-ethernet