我正在關注sparkfun tutorial for connecting an arduino to electric imp。我只有一個arduino和imp,所以我試圖通過使用server.show()
來獲得我在arduino串行監視器中輸入的內容,以便在imp節點中顯示。使用ElectricImp server.show()和Arduino
我修改在sparkfun代碼的功能看起來像這樣的:
function pollUart()
{
imp.wakeup(0.00001, pollUart.bindenv(this)); // schedule the next poll in 10us
local byte = hardware.uart57.read(); // read the UART buffer
// This will return -1 if there is no data to be read.
while (byte != -1) // otherwise, we keep reading until there is no data to be read.
{
// server.log(format("%c", byte)); // send the character out to the server log. Optional, great for debugging
// impeeOutput.set(byte); // send the valid character out the impee's outputPort
server.show(byte)
byte = hardware.uart57.read(); // read from the UART buffer again (not sure if it's a valid character yet)
toggleTxLED(); // Toggle the TX LED
}
}
server.show(byte)
只顯示看似隨機數。我有一個想法,爲什麼這是,我只是不知道如何解決它,因爲我不熟悉UART和松鼠。
local byte = hardware.uart57.read();
從字節形式(我認爲)從arduino讀取ascii字符,並且在我使用server.show(byte)
之前,它們沒有被「翻譯」成它們的ASCII字符。 我該如何做松鼠? 另外,我認爲每10us輪詢是錯誤的方式去這裏。我只想在有新信息時進行輪詢,但我也不知道如何以松鼠的方式做到這一點。有人能指出我發生這種情況的一個例子嗎?
謝謝!
您是否能夠將您的Electric Imp連接到無線路由器,因爲我無法使用我的無線路由器配置Electric Imp。 – shailendra