http://gharee.com/wiki/index.php?action=history&feed=atom&title=SKU%3ARB-02S037_ADXL345%E6%95%B0%E5%AD%97%E4%B8%89%E8%BD%B4%E5%8A%A0%E9%80%9F%E5%BA%A6%E8%AE%A1
123,123
2025-06-28T04:34:45Z
本wiki的該頁面的版本歷史
MediaWiki 1.21.2
http://gharee.com/wiki/index.php?title=SKU:RB-02S037_ADXL345%E6%95%B0%E5%AD%97%E4%B8%89%E8%BD%B4%E5%8A%A0%E9%80%9F%E5%BA%A6%E8%AE%A1&diff=8534&oldid=prev
Zhangxin:/* 資料下載 */
2021-12-09T09:10:10Z
<p>?<span dir="auto"><span class="autocomment">資料下載</span></span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">←上一版本</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">2021年12月9日 (四) 09:10的版本</td>
</tr><tr><td colspan="2" class="diff-lineno">第141行:</td>
<td colspan="2" class="diff-lineno">第141行:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:erweima.png|230px|無框|右]]</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:erweima.png|230px|無框|右]]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* 產(chǎn)品資料</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* 產(chǎn)品資料</div></td></tr>
<tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>下載鏈接:https://pan.baidu.com/s/<del class="diffchange diffchange-inline">1HRYZ4-6ONWKiLqgcwUilLw </del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>下載鏈接:https://pan.baidu.com/s/<ins class="diffchange diffchange-inline">1Sv8WBvom06wjt_ri_okrvg </ins></div></td></tr>
<tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">提取碼:z70z  <br/></del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">提取碼:0af1</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* 產(chǎn)品購買鏈接:http://gharee.com/goods-766.html</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* 產(chǎn)品購買鏈接:http://gharee.com/goods-766.html</div></td></tr>
</table>
Zhangxin
http://gharee.com/wiki/index.php?title=SKU:RB-02S037_ADXL345%E6%95%B0%E5%AD%97%E4%B8%89%E8%BD%B4%E5%8A%A0%E9%80%9F%E5%BA%A6%E8%AE%A1&diff=8056&oldid=prev
Arduino77:/* 產(chǎn)品相關推薦 */
2018-09-28T09:31:28Z
<p>?<span dir="auto"><span class="autocomment">產(chǎn)品相關推薦</span></span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">←上一版本</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">2018年9月28日 (五) 09:31的版本</td>
</tr><tr><td colspan="2" class="diff-lineno">第138行:</td>
<td colspan="2" class="diff-lineno">第138行:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[File:san zhou 01.png|400px|居中|link=http://v.youku.com/v_show/id_XMzkzMjE2NzM2.html?from=y1.7-2]]</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[File:san zhou 01.png|400px|居中|link=http://v.youku.com/v_show/id_XMzkzMjE2NzM2.html?from=y1.7-2]]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div><br/></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div><br/></div></td></tr>
<tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>==<del class="diffchange diffchange-inline">產(chǎn)品相關推薦</del>==</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>==<ins class="diffchange diffchange-inline">資料下載</ins>==</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:erweima.png|230px|無框|右]]</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[文件:erweima.png|230px|無框|右]]</div></td></tr>
<tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">===產(chǎn)品購買地址===</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">* 產(chǎn)品資料</ins></div></td></tr>
<tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">[http</del>://<del class="diffchange diffchange-inline">item</del>.<del class="diffchange diffchange-inline">taobao</del>.com/<del class="diffchange diffchange-inline">item.htm?spm=a1z10.3</del>-<del class="diffchange diffchange-inline">c.w4002-3667083713.12.MXloI1&id=13280714814 Arduino ADXL345 三軸加速度計 ]<br/></del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">下載鏈接:https</ins>://<ins class="diffchange diffchange-inline">pan</ins>.<ins class="diffchange diffchange-inline">baidu</ins>.com/<ins class="diffchange diffchange-inline">s/1HRYZ4</ins>-<ins class="diffchange diffchange-inline">6ONWKiLqgcwUilLw </ins></div></td></tr>
<tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">===周邊產(chǎn)品推薦===</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">提取碼:z70z  </ins><br/></div></td></tr>
<tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">[http://gharee.com/goods-546.html Carduino UNO R3 控制器]</del><br/></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins class="diffchange diffchange-inline">* 產(chǎn)品購買鏈接:http</ins>://gharee.com/goods-<ins class="diffchange diffchange-inline">766</ins>.html</div></td></tr>
<tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">[http</del>://gharee.com/goods-<del class="diffchange diffchange-inline">147</del>.html <del class="diffchange diffchange-inline">V5.0傳感器擴展板]<br/></del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></div></td></tr>
<tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">===相關問題解答===</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></div></td></tr>
<tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">[http://www.makerspace.cn/forum.php?mod=viewthread&tid=3904&fromuid=10780 如何使用stm8s103f3單片機控制adxl345三軸加速度傳感器]<br/></del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></div></td></tr>
<tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">===相關學習資料===</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></div></td></tr>
<tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">[http://pan.baidu.com/s/1ntIkk6t ADXL345 芯片中文版說明書下載]<br/></del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></div></td></tr>
<tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">[http://v.youku.com/v_show/id_XMzkzMjE2NzM2.html?from=y1.7-2 視頻: AS-4WD輪式機器人三軸加速度計操控功能演示]<br/></del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></div></td></tr>
<tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">[http://www.makerspace.cn/forum.php?mod=viewthread&tid=1733&fromuid=10780 視頻:Arduino ADXL345 三軸加速度計]<br/></del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></div></td></tr>
<tr><td class='diff-marker'>?</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">[http://www.makerspace.cn/portal.php 奧松機器人技術論壇]<br/></del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></div></td></tr>
</table>
Arduino77
http://gharee.com/wiki/index.php?title=SKU:RB-02S037_ADXL345%E6%95%B0%E5%AD%97%E4%B8%89%E8%BD%B4%E5%8A%A0%E9%80%9F%E5%BA%A6%E8%AE%A1&diff=5962&oldid=prev
Arduino77:以“右 ==產(chǎn)品概述== ADXL345 數(shù)字三軸加速度計是一款小而薄的超低功耗3軸加速度計,分辨率高達(13位)...”為內容創(chuàng)建頁面
2016-06-22T06:36:13Z
<p>以“<a href="/wiki/index.php/%E6%96%87%E4%BB%B6:02s03701.png" title="文件:02s03701.png">右</a> ==產(chǎn)品概述== ADXL345 數(shù)字三軸加速度計是一款小而薄的超低功耗3軸加速度計,分辨率高達(13位)...”為內容創(chuàng)建頁面</p>
<p><b>新頁面</b></p><div>[[文件:02s03701.png|500px|有框|右]]<br />
==產(chǎn)品概述==<br />
ADXL345 數(shù)字三軸加速度計是一款小而薄的超低功耗3軸加速度計,分辨率高達(13位),測量范圍達± 16g。數(shù)字輸出數(shù)據(jù)為16位二進制補碼格式,可通過SPI(3線或4線)或I2C數(shù)字接口訪問。ADXL345非常適合移動設備應用。它可以在傾斜檢測應用中測量靜態(tài)重力加速度,還可以測量運動或沖擊導致的動態(tài)加速度。其高分辨率(3.9mg/LSB),能夠測量不到1.0°的傾斜角度變化。該器件提供多種特殊檢測功能?;顒雍头腔顒訖z測功能通過比較任意軸上的加速度與用戶設置的閾值來檢測有無運動發(fā)生。敲擊檢測功能可以檢測任意方向的單振和雙振動作。自由落體檢測功能可以檢測器件是否正在掉落。這些功能可以獨立映射到兩個中斷輸出引腳中的一個。正在申請專利的集成式存儲器管理系統(tǒng)采用一個32級先進先出(FIFO)緩沖器,可用于存儲數(shù)據(jù),從而將主機處理器負荷降至最低,并降低整體系統(tǒng)功耗。低功耗模式支持基于運動的智能電源管理,從而以極低的功耗進行閾值感測和運動加速度測量。<br />
==規(guī)格參數(shù)==<br />
# 工作電壓:3.3-5v<br />
# 超低功耗:測量模式下 40uA 電流損耗,待機模式下0.1uA @2.5v<br />
# 通訊接口:I2C、SPI (3線 or 4線)<br />
# 接口類型:0.1"插針孔<br />
# 信號類型:數(shù)字信號<br />
==接口定義==<br />
* VCC:電源引腳<br />
* GND:該引腳必須接地<br />
* CS:片選端,低電平有效<br />
* INT1:中斷1輸出<br />
* INT2:中斷2輸出<br />
* SDO:備用I2C地址選擇<br />
* SDA:I2C接口數(shù)據(jù)端<br />
* SCL:I2C接口時鐘端<br />
==使用方法==<br />
===工作原理===<br />
ADXL345 加速度傳感器首先由前端感應器件感測加速度的大小,然后由感應電信號器件轉為可識別的電信號,這個信號是模擬信號,ADXL345 中集成了 AD 轉換器,可以將模擬信號數(shù)字化,我們知道在計算機系統(tǒng)中數(shù)字信號一律用補碼的形式來表示,在這也是如此,AD 轉換器輸出的是 16位的二進制補碼,經(jīng)過數(shù)字濾波器的濾波后在控制和中斷邏輯單元的控制下訪問32級 FIFO,通過串行接口讀取數(shù)據(jù)。ADXL345 的控制命令也是通過接受來自串口的讀寫命令來實現(xiàn)的,這主要是對寄存器的操作。<br />
===編程原理===<br />
使用 IIC 通信連接 ADXL345 和 Arduino UNO 控制器(連線方法詳見下圖),使用 ±2g 加速度測試模式,通過查看 ADXL345 芯片手冊,可以對芯片地址進行設置,該器件還提供了多種特殊檢測功能,活動和非活動檢測功能通過比較任意軸上的加速度與用戶設置閥值來檢測有無運動發(fā)生。敲擊檢測功能可以檢測任意方向的單振和雙振動作。自由落體檢測功能可以檢測器件是否正在掉落。這些功能可以獨立映像到兩個中斷輸出引腳中的一個。集成式內存管理系統(tǒng)采用一個32級先進先出緩沖期,用于數(shù)據(jù)存儲,從而將主機處理器負荷降至最低,并降低整體系統(tǒng)功耗。<br />
===接線方法===<br />
{|border="1" cellspacing="0" align="center" cellpadding="5" width="400px"<br />
|-<br />
|align="center"|ADXL345<br />
|align="center"|Arduino<br />
|-<br />
|align="center"|VCC<br />
|align="center"|3V3<br />
|-<br />
|align="center"|GND<br />
|align="center"|GND<br />
|-<br />
|align="center"|CS<br />
|align="center"|3V3<br />
|-<br />
|align="center"|SDO<br />
|align="center"|GND<br />
|-<br />
|align="center"|SDA<br />
|align="center"|A4<br />
|-<br />
|align="center"|SCL<br />
|align="center"|A5<br />
<br />
|}<br />
<br><br />
接線圖:<br />
[[文件:adxl345jiexian.jpg|700px|有框|居中]]<br />
===例子程序===<br />
[http://pan.baidu.com/s/1o6CI1ZG wire庫文件下載] <br/><br />
<pre style="color:blue"><br />
#include <Wire.h><br />
#define DEVICE (0x53) //ADXL345 device address<br />
#define TO_READ (6) //num of bytes we are going to read each time (two bytes for each axis)<br />
byte buff[TO_READ] ; //6 bytes buffer for saving data read from the device<br />
char str[512]; //string buffer to transform data before sending it to the serial port<br />
int regAddress = 0x32; //first axis-acceleration-data register on the ADXL345<br />
int x, y, z; //three axis acceleration data<br />
double roll = 0.00, pitch = 0.00; //Roll & Pitch are the angles which rotate by the axis X and y <br />
//in the sequence of R(x-y-z),more info visit<br />
void setup() {<br />
Wire.begin(); // join i2c bus (address optional for master)<br />
Serial.begin(9600); // start serial for output<br />
<br />
//Turning on the ADXL345<br />
writeTo(DEVICE, 0x2D, 0); <br />
writeTo(DEVICE, 0x2D, 16);<br />
writeTo(DEVICE, 0x2D, 8);<br />
}<br />
<br />
void loop() {<br />
<br />
readFrom(DEVICE, regAddress, TO_READ, buff); //read the acceleration data from the ADXL345<br />
//each axis reading comes in 10 bit resolution, ie 2 bytes. Least Significat Byte first!!<br />
//thus we are converting both bytes in to one int<br />
x = (((int)buff[1]) << 8) | buff[0]; <br />
y = (((int)buff[3])<< 8) | buff[2];<br />
z = (((int)buff[5]) << 8) | buff[4];<br />
//we send the x y z values as a string to the serial port<br />
Serial.print("The acceleration info of x, y, z are:");<br />
sprintf(str, "%d %d %d", x, y, z); <br />
Serial.print(str);<br />
Serial.write(10);<br />
//Roll & Pitch calculate<br />
RP_calculate();<br />
Serial.print("Roll:"); Serial.println( roll ); <br />
Serial.print("Pitch:"); Serial.println( pitch );<br />
Serial.println("");<br />
//It appears that delay is needed in order not to clog the port<br />
delay(50);<br />
}<br />
<br />
//---------------- Functions<br />
//Writes val to address register on device<br />
void writeTo(int device, byte address, byte val) {<br />
Wire.beginTransmission(device); //start transmission to device <br />
Wire.write(address); // send register address<br />
Wire.write(val); // send value to write<br />
Wire.endTransmission(); //end transmission<br />
}<br />
<br />
//reads num bytes starting from address register on device in to buff array<br />
void readFrom(int device, byte address, int num, byte buff[]) {<br />
Wire.beginTransmission(device); //start transmission to device <br />
Wire.write(address); //sends address to read from<br />
Wire.endTransmission(); //end transmission<br />
<br />
Wire.beginTransmission(device); //start transmission to device<br />
Wire.requestFrom(device, num); // request 6 bytes from device<br />
<br />
int i = 0;<br />
while(Wire.available()) //device may send less than requested (abnormal)<br />
{ <br />
buff[i] = Wire.read(); // receive a byte<br />
i++;<br />
}<br />
Wire.endTransmission(); //end transmission<br />
}<br />
<br />
//calculate the Roll&Pitch<br />
void RP_calculate(){<br />
double x_Buff = float(x);<br />
double y_Buff = float(y);<br />
double z_Buff = float(z);<br />
roll = atan2(y_Buff , z_Buff) * 57.3;<br />
pitch = atan2((- x_Buff) , sqrt(y_Buff * y_Buff + z_Buff * z_Buff)) * 57.3;<br />
}<br />
</pre><br />
===程序效果===<br />
打開串口監(jiān)視窗口,可以看到類似下圖的數(shù)據(jù),分別為:三軸加速度的數(shù)據(jù),按照R-xyz旋轉順序時的[http://blog.csdn.net/yuzhongchun/article/details/22749521 姿態(tài)角]。按各軸旋轉可以觀測到相應的數(shù)據(jù)變化。<br />
[[文件:02s03710.png|404px|有框|居中]]<br />
<br />
==視頻演示==<br />
[[File:san zhou 02.png|400px|左|link=http://v.youku.com/v_show/id_XMjAwNDEzMjQw.html?from=y1.7-2]]<br />
[[File:san zhou 01.png|400px|居中|link=http://v.youku.com/v_show/id_XMzkzMjE2NzM2.html?from=y1.7-2]]<br />
<br/><br />
==產(chǎn)品相關推薦==<br />
[[文件:erweima.png|230px|無框|右]]<br />
===產(chǎn)品購買地址===<br />
[http://item.taobao.com/item.htm?spm=a1z10.3-c.w4002-3667083713.12.MXloI1&id=13280714814 Arduino ADXL345 三軸加速度計 ]<br/><br />
===周邊產(chǎn)品推薦===<br />
[http://gharee.com/goods-546.html Carduino UNO R3 控制器]<br/><br />
[http://gharee.com/goods-147.html V5.0傳感器擴展板]<br/><br />
===相關問題解答===<br />
[http://www.makerspace.cn/forum.php?mod=viewthread&tid=3904&fromuid=10780 如何使用stm8s103f3單片機控制adxl345三軸加速度傳感器]<br/><br />
===相關學習資料===<br />
[http://pan.baidu.com/s/1ntIkk6t ADXL345 芯片中文版說明書下載]<br/><br />
[http://v.youku.com/v_show/id_XMzkzMjE2NzM2.html?from=y1.7-2 視頻: AS-4WD輪式機器人三軸加速度計操控功能演示]<br/><br />
[http://www.makerspace.cn/forum.php?mod=viewthread&tid=1733&fromuid=10780 視頻:Arduino ADXL345 三軸加速度計]<br/><br />
[http://www.makerspace.cn/portal.php 奧松機器人技術論壇]<br/></div>
Arduino77