“轨迹球模块”的版本间的差异
来自YFRobotwiki
(以“ 倾角传感器模块 === 产品简介 === <br> 倾角传感器模块采用SW520双滚珠开关设计制作。SW520滚...”为内容创建页面) |
|||
(未显示1个用户的8个中间版本) | |||
第1行: | 第1行: | ||
− | [[Image: | + | [[Image: 轨迹球模块.jpg|400px|thumb| 轨迹球 模块]] |
第6行: | 第6行: | ||
=== 产品简介 === | === 产品简介 === | ||
<br> | <br> | ||
− | + | 轨迹球 模块采 用黑莓轨迹球 设计制作 ,模块可以通过 滚 轮运动传动X和Y方 向 的转轴,通过固定在转轴上的多极充磁磁体转动,对相 应 的SMD霍尔元件 发 出信号,从而确 定 运动轨迹。轨迹球下方还设计了一个小SMD 开关, 方便 用 户进行触发事件或“点击”选择 。 | |
第20行: | 第20行: | ||
− | === | + | === 引脚说明 === |
<br> | <br> | ||
− | |||
+ | {|border="1" cellspacing="0" align="center" cellpadding="5" width="700px" | ||
+ | |- | ||
+ | |align="left"|'''名称''' | ||
+ | |align="left"|'''说明''' | ||
+ | |- | ||
+ | |align="left"|RHT | ||
+ | |align="left"|Sign - right | ||
+ | |- | ||
+ | |align="left"|LET | ||
+ | |align="left"|Sign - left | ||
+ | |- | ||
+ | |align="left"|DWN | ||
+ | |align="left"|Sign - down | ||
+ | |- | ||
+ | |align="left"|UP | ||
+ | |align="left"|Sign - up | ||
+ | |- | ||
+ | |align="left"|KEY | ||
+ | |align="left"|Sign - key | ||
+ | |- | ||
+ | |align="left"|VCC | ||
+ | |align="left"|电源+5V | ||
+ | |- | ||
+ | |align="left"|GND | ||
+ | |align="left"|地 | ||
− | + | |} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
第38行: | 第57行: | ||
:'''电路连接示意图''' | :'''电路连接示意图''' | ||
<br> | <br> | ||
− | + | ||
+ | {|border="1" cellspacing="0" align="center" cellpadding="5" width="700px" | ||
+ | |- | ||
+ | |align="left"|''' 轨迹球 模块''' | ||
+ | |align="left"|'''Arduino UNO''' | ||
+ | |- | ||
+ | |align="left"|RHT | ||
+ | |align="left"|D4 | ||
+ | |- | ||
+ | |align="left"|LET | ||
+ | |align="left"|D3 | ||
+ | |- | ||
+ | |align="left"|DWN | ||
+ | |align="left"|D6 | ||
+ | |- | ||
+ | |align="left"|UP | ||
+ | |align="left"|D5 | ||
+ | |- | ||
+ | |align="left"|KEY | ||
+ | |align="left"|D2 | ||
+ | |- | ||
+ | |align="left"|VCC | ||
+ | |align="left"|电源+5V | ||
+ | |- | ||
+ | |align="left"|GND | ||
+ | |align="left"|地 | ||
+ | |||
+ | |} | ||
− | <!--[[Image: | + | <!--[[Image: 轨迹球 模块.jpg|400px|center| 轨迹球 模块接线图]]--> |
:'''示例代码''' | :'''示例代码''' | ||
− | < | + | <source lang="c"> |
− | // | + | /************************************************************************** |
+ | BlackBerry Trackballer Breakout Demo | ||
+ | ***************************************************************************/ | ||
+ | //Define Trackballer Breakout pin connections to Arduino | ||
+ | #define Btn 2 | ||
+ | #define Lft 3 | ||
+ | #define Rht 4 | ||
+ | #define Up 5 | ||
+ | #define Dwn 6 | ||
− | + | //Define variables used in sketch | |
− | + | int buttonClick; | |
+ | unsigned long mouse_Lft; | ||
+ | unsigned long old_mouse_Lft; | ||
+ | unsigned long mouse_Rht; | ||
+ | unsigned long old_mouse_Rht; | ||
+ | unsigned long mouse_Up; | ||
+ | unsigned long old_mouse_Up; | ||
+ | unsigned long mouse_Dwn; | ||
+ | unsigned long old_mouse_Dwn; | ||
+ | int x_position; | ||
+ | int y_position; | ||
+ | /*********************Setup Loop*************************/ | ||
void setup() { | void setup() { | ||
− | pinMode( | + | |
+ | //Define pin functionality on the Arduino | ||
+ | pinMode(Btn, INPUT); | ||
+ | pinMode(Lft, INPUT); | ||
+ | pinMode(Rht, INPUT); | ||
+ | pinMode(Up, INPUT); | ||
+ | pinMode(Dwn, INPUT); | ||
+ | |||
+ | //Start Serial port for debugging. | ||
+ | Serial.begin(9600); | ||
+ | Serial.println("Begin Trackballer Demo"); | ||
+ | delay(1000); | ||
+ | Serial.println("Begin Trackball tracking"); | ||
} | } | ||
+ | |||
+ | |||
+ | /*********************Main Loop*************************/ | ||
void loop() { | void loop() { | ||
+ | //read the pin state | ||
+ | mouse_Lft = digitalRead(Lft); | ||
+ | mouse_Rht = digitalRead(Rht); | ||
+ | if (mouse_Lft != old_mouse_Lft) | ||
+ | { | ||
+ | x_position = --x_position; | ||
+ | old_mouse_Lft = mouse_Lft; | ||
+ | Serial.print("Trackball Position: \t X-Position= "); | ||
+ | Serial.println(x_position); | ||
+ | } | ||
+ | if (mouse_Rht != old_mouse_Rht) | ||
+ | { | ||
+ | x_position = ++x_position; | ||
+ | old_mouse_Rht = mouse_Rht; | ||
+ | Serial.print("Trackball Position: \t X-Position= "); | ||
+ | Serial.println(x_position); | ||
+ | } | ||
+ | delay(50); | ||
+ | //read the pin state | ||
+ | mouse_Up = digitalRead(Up); | ||
+ | mouse_Dwn = digitalRead(Dwn); | ||
+ | if (mouse_Up != old_mouse_Up) | ||
+ | { | ||
+ | y_position = ++y_position; | ||
+ | old_mouse_Up = mouse_Up; | ||
+ | Serial.print("Trackball Position: \t \t Y-position= "); | ||
+ | Serial.println(y_position); | ||
+ | } | ||
+ | if (mouse_Dwn != old_mouse_Dwn) | ||
+ | { | ||
+ | y_position = --y_position; | ||
+ | old_mouse_Dwn = mouse_Dwn; | ||
+ | Serial.print("Trackball Position: \t \t Y-position= "); | ||
+ | Serial.println(y_position); | ||
+ | } | ||
+ | delay(50); | ||
− | + | //Check for button click. If present, print to Serial monitor. | |
− | + | buttonClick = digitalRead(Btn); | |
− | + | if (buttonClick == LOW) | |
− | + | { | |
+ | Serial.println("Click"); | ||
+ | } | ||
} | } | ||
− | </ | + | </source> |
− | 程序下载地址:[ | + | 程序下载地址:[https://eyun.baidu.com/s/3mispQPU BlackBerry_Trackballer_Breakout_Demo] |
− | 程序运行结果: | + | 程序运行结果: 转动轨迹球 , 串口输出X、Y轴位置信息 ,点 击按键串口输出“Click” 。 串口监视器截图: |
+ | [[Image:轨迹球串口输出.png|center|轨迹球串口输出]] | ||
+ | |||
+ | [http://www.yfrobot.com/thread-11709-1-1.html 教程地址附视频] | ||
===参考资料=== | ===参考资料=== | ||
<br> | <br> | ||
− | |||
第80行: | 第200行: | ||
[[首页 | 返回首页]] | [[首页 | 返回首页]] | ||
+ | |||
+ | 欢迎交流加入群聊-[https://jq.qq.com/?_wv=1027&k=466mOjv 技术交流群] | ||
更多建议和问题欢迎反馈至 [http://www.yfrobot.com YFRobot论坛] | 更多建议和问题欢迎反馈至 [http://www.yfrobot.com YFRobot论坛] | ||
购买方式:[http://yfrobot.taobao.com/ YFRobot 电子工作室] | 购买方式:[http://yfrobot.taobao.com/ YFRobot 电子工作室] |
2020年4月10日 (五) 11:26的最后版本
生成缩略图出错:文件可能丢失:
产品简介
轨迹球模块采用黑莓轨迹球设计制作,模块可以通过滚轮运动传动X和Y方向的转轴,通过固定在转轴上的多极充磁磁体转动,对相应的SMD霍尔元件发出信号,从而确定运动轨迹。轨迹球下方还设计了一个小SMD开关,方便用户进行触发事件或“点击”选择。
规格参数
- 供电电压:DC3.3 - 5V
- 安装孔径:3MM
- 模块尺寸:28*21*15.7MM(长*宽*高)
- 孔间距:15MM
- 模块重量:2.5g
引脚说明
名称 | 说明 |
RHT | Sign - right |
LET | Sign - left |
DWN | Sign - down |
UP | Sign - up |
KEY | Sign - key |
VCC | 电源+5V |
GND | 地 |
应用示例
- 电路连接示意图
轨迹球模块 | Arduino UNO |
RHT | D4 |
LET | D3 |
DWN | D6 |
UP | D5 |
KEY | D2 |
VCC | 电源+5V |
GND | 地 |
- 示例代码
/************************************************************************** BlackBerry Trackballer Breakout Demo ***************************************************************************/ //Define Trackballer Breakout pin connections to Arduino #define Btn 2 #define Lft 3 #define Rht 4 #define Up 5 #define Dwn 6 //Define variables used in sketch int buttonClick; unsigned long mouse_Lft; unsigned long old_mouse_Lft; unsigned long mouse_Rht; unsigned long old_mouse_Rht; unsigned long mouse_Up; unsigned long old_mouse_Up; unsigned long mouse_Dwn; unsigned long old_mouse_Dwn; int x_position; int y_position; /*********************Setup Loop*************************/ void setup() { //Define pin functionality on the Arduino pinMode(Btn, INPUT); pinMode(Lft, INPUT); pinMode(Rht, INPUT); pinMode(Up, INPUT); pinMode(Dwn, INPUT); //Start Serial port for debugging. Serial.begin(9600); Serial.println("Begin Trackballer Demo"); delay(1000); Serial.println("Begin Trackball tracking"); } /*********************Main Loop*************************/ void loop() { //read the pin state mouse_Lft = digitalRead(Lft); mouse_Rht = digitalRead(Rht); if (mouse_Lft != old_mouse_Lft) { x_position = --x_position; old_mouse_Lft = mouse_Lft; Serial.print("Trackball Position: \t X-Position= "); Serial.println(x_position); } if (mouse_Rht != old_mouse_Rht) { x_position = ++x_position; old_mouse_Rht = mouse_Rht; Serial.print("Trackball Position: \t X-Position= "); Serial.println(x_position); } delay(50); //read the pin state mouse_Up = digitalRead(Up); mouse_Dwn = digitalRead(Dwn); if (mouse_Up != old_mouse_Up) { y_position = ++y_position; old_mouse_Up = mouse_Up; Serial.print("Trackball Position: \t \t Y-position= "); Serial.println(y_position); } if (mouse_Dwn != old_mouse_Dwn) { y_position = --y_position; old_mouse_Dwn = mouse_Dwn; Serial.print("Trackball Position: \t \t Y-position= "); Serial.println(y_position); } delay(50); //Check for button click. If present, print to Serial monitor. buttonClick = digitalRead(Btn); if (buttonClick == LOW) { Serial.println("Click"); } }
程序下载地址:BlackBerry_Trackballer_Breakout_Demo
程序运行结果:转动轨迹球,串口输出X、Y轴位置信息,点击按键串口输出“Click”。串口监视器截图:
参考资料
欢迎交流加入群聊-技术交流群
更多建议和问题欢迎反馈至 YFRobot论坛
购买方式:YFRobot 电子工作室