Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 5315|回復: 2
打印 上一主題 下一主題

請問有人使用過Arduino與K NET(ZIGBEE)做連接嗎??

[複製鏈接]
跳轉到指定樓層
1#
發表於 2009-11-26 09:36:56 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
請問各位Arduino在與ZIGBEE做連結時,如果需要制定一個封包格式該如何制定??
假設封包為204 08 25 0 0 0 0 2 5 255
我在Arduino的程式語法該如何寫??
我嘗試用10個變數套入可是Arduino會自動幫我把這些數字加總...
有人可以幫忙解答一下嗎?
2#
發表於 2009-11-26 14:50:38 | 只看該作者
應該使用"字串"型態
char ...
應能解決問題
變數通常指數字, 當然會被加總啊
3#
發表於 2009-12-23 19:01:26 | 只看該作者
請問各位Arduino在與ZIGBEE做連結時,如果需要制定一個封包格式該如何制定??
假設封包為204 08 25 0 0 0 0 2 5 255
我在Arduino的程式語法該如何寫??
我嘗試用10個變數套入可是Arduino會自動幫我把這些數字加總.. ...
han12676 發表於 2009-11-26 09:36


Arduino 會自動把數字加總?這是何意?

你是要把數值放到 10 個變數嗎?不嫌麻煩的話,可以用 sscanf:

char str[72] = "204 08 25 0 0 0 0 2 5 255";
int readings[10];
sscanf(str, "%d %d %d %d %d %d %d %d %d %d", readings[0], readings[1], readings[2], readings[3], readings[4], readings[5], readings[6], readings[7], readings[8], readings[9]);

Serial.println(readings[0]);
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2024-5-23 19:03 , Processed in 0.333176 second(s), 8 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表