mirror of
https://github.com/m5stack/m5-docs.git
synced 2026-05-20 10:23:01 -07:00
3.4 KiB
3.4 KiB
Module JOYSTICK
SKU:A007
描述
JOYSTICK 是一款兼容 FACE 套件的摇杆控制面板.通过推动面板上的摇杆能够进行角度、方向等数据的输入.使用I2C协议通讯,能够获取摇杆的偏移数据(X,Y坐标),以及中间按钮的状态.在摇杆的周围嵌入了由12个LED组成的LED bar,你可以根据你的需求自定义LED灯的发光形式.
产品特性
- 4 RGB Led
- I2C 通讯(0x5E)
- 简洁的API接口
包含
- 1x M5Stack JOYSTICK 模块
- 1x Joystick 摇杆
规格参数
| 规格 | 参数 |
| 净重 | 22g |
| 毛重 | 50g |
| 产品尺寸 | 58*54*10mm |
| 包装尺寸 | 95*65*25mm |
相关链接
EasyLoader
1.EasyLoader是一个简洁快速的程序烧录器,每一个产品页面里的EasyLoader都提供了一个与产品相关的案例程序,通过简单步骤将其烧录至主控,能够进行一系列的功能验证.
2.下载软件后,双击运行应用程序,将M5设备通过数据线连接至电脑,选择端口参数,点击 "Burn" 即可开始烧录
?>3.EasyLoader烧录前需要安装有CP210X(USB驱动程序),点击此处查看驱动安装教程
管脚映射
Mega328 ISP下载接口Pin脚定义
案例程序
1. Arduino
UIFLOW
功能函数
控制RGB灯圈
/*
Parameter:
indexOfLED: 0 ~ 11
r, g, b: 0 ~ 254
*/
void Led(int indexOfLED, int r, int g, int b){
Wire.beginTransmission(FACE_JOY_ADDR);
Wire.write(indexOfLED);
Wire.write(r);
Wire.write(g);
Wire.write(b);
Wire.endTransmission();
}
读取摇杆各个方向的偏移量
void get_joystick_offset(void){
Wire.requestFrom(FACE_JOY_ADDR, 5);
if (Wire.available()) {
y_data_L = Wire.read();
y_data_H = Wire.read();
x_data_L = Wire.read();
x_data_H = Wire.read();
button_data = Wire.read();// Z(0: released 1: pressed)
}
<script>
var purchase_link = 'https://m5stack.com/collections/m5-module/products/joystick-module';
anchor_search(purchase_link);
scrollFunc();
</script>
