This commit is contained in:
LiHuashen
2019-02-18 09:52:18 +08:00
parent f6df00cccd
commit c78e182b56
6 changed files with 82 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

+1 -1
View File
@@ -10,7 +10,7 @@
## 描述
**<mark>Joystick</mark>**是一款内置MEGA328芯片控制的摇杆模块,可以输出X-Y两个方向的摇杆偏移量,可以判断Z方向是否按下的。
**<mark>Joystick</mark>** 是一款内置MEGA328芯片控制的摇杆模块,可以输出X-Y两个方向的摇杆偏移量,可以判断Z方向是否按下的。
内部电路里,摇杆的X方向与MEGA328的A0管脚相连,Y方向与MEGA328的A1管脚相连,Z方向与MEGA的A2管脚相连。
+81
View File
@@ -0,0 +1,81 @@
# TRACE - 巡线 Unit {docsify-ignore-all}
<img src="assets/img/product_pics/unit/unit_trace_01.png" width="30%" height="30%">
***
:memo:**[描述](#描述)**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:octocat:**[例程](#例程)**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:electric_plug:**[原理图](#原理图)**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;🛒**[购买链接](https://item.taobao.com/item.htm?spm=a1z10.3-c.w4002-1172588106.12.4c32425eGaqxO8&id=587199991600)**
## 描述
**<mark>TRACE</mark>** 是一款内置 4 组光电对管和 MEGA328 芯片的巡线模块。
TRACE Unit 同样也是通过 IIC 与主控通信,其I2C地址是0x5A。与 M5Core 相连时,接在 GROVE A 口。
<img src="assets/img/product_pics/unit/unit_trace_03.png" width="30%" height="30%">
## 特性
- 工作范围:反射面距离光电对管面小于 11mm
- GROVE接口,支持[UiFlow](http://flow.m5stack.com)编程,[Arduino](http://www.arduino.cc)编程
## 相关链接
- **[官方频道视频](https://i.youku.com/i/UNjE1ODA2MzE0OA==?spm=a2hzp.8253869.0.0)**
- **[官方论坛](http://forum.m5stack.com/)**
<!-- - **[模块内MEGA328固件](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Unit/Makey_NewVersion/firmware_328p)** -->
## 例程
### 1. Arduino IDE
*以下仅为用法示意,并不完整。如果需要完整例程请点击[这里](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Unit/TRACE/Arduino)。*
```arduino
#include <M5Stack.h>
#include "Wire.h"
#define JOY_ADDR 0x52
// declaration
#define VALUE_SPLIT
uint8_t value;
int sensorValue[4] = {0};
// initialization
M5.begin();
M5.Lcd.clear();
dacWrite(25, 0);//disable the speak noise
Wire.begin(21, 22, 400000);
// read data
Wire.requestFrom(JOY_ADDR, 3);
if (Wire.available()) {
x_data = Wire.read();// X(range: 10~250)
y_data = Wire.read();// Y(range: 10~250)
button_data = Wire.read();// Z(0: released 1: pressed)
sprintf(data, "x:%d y:%d button:%d\n", x_data, y_data, button_data);
}
```
### 2. UIFlow
*具体例程请点击[这里](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Unit/TRACE/UIFlow)。*
<img src="assets/img/product_pics/unit/unit_example/TRACE/example_unit_trace_01.png">
<!-- ## 原理图
<img src="assets/img/product_pics/unit/trace_sch.png"> -->
### 管脚映射
<table>
<tr><td>M5Core(GROVE接口A)</td><td>GPIO22</td><td>GPIO21</td><td>5V</td><td>GND</td></tr>
<tr><td>TRACE Unit</td><td>SCL</td><td>SDA</td><td>5V</td><td>GND</td></tr>
</table>