回答

收藏

关于arduino控制android手机的方案如 Amarino

#开源分享 #开源分享 3312 人阅读 | 0 人回复 | 2013-09-11

搜索 android arduino 资料,看了一圈,很多都是从 android 控制 arduino 的。 貌似 Amarino 这个比较靠谱:


Amarino is a toolkit to connect Android-driven mobile devices with Arduino microcontrollers via Bluetooth. The toolkit provides easy access to internal phone events which can be further processed on the Arduino open-source prototyping platform.

这句话我理解主要是 arduino 去操作 android , 应该是是操作各种 android 机组件,比如摄像头、sd卡、gps等各种手机传感器---没确认目前支持的传感器列表,原理应该很简单,就是连接蓝牙以后,通过串口通信交流指令。我理解不难实现,我都想自己搞个 python 版的类似桥接工具了。

  1. /*
  2. * Receives compass sensor events from your phone.
  3. */
  4. #include <MeetAndroid.h>

  5. MeetAndroid meetAndroid(error);

  6. void error(uint8_t flag, uint8_t values){
  7. meetAndroid.send("ERROR: ");
  8. meetAndroid.send(flag);
  9. }

  10. void setup() {
  11. Serial.begin(57600);
  12. meetAndroid.registerFunction(compass, 'A');
  13. }

  14. void loop() {
  15. meetAndroid.receive(); // you need to keep this in your loop() to receive events
  16. }

  17. /*
  18. * Compass events are sent several times a second.
  19. * therefore this method will be called constantly.
  20. *
  21. * note: flag is in this case 'A' and numOfValues is 1
  22. * since compass event sends exactly one single int value for heading
  23. */
  24. void compass(byte flag, byte numOfValues) {
  25. // we use getInt(), since we know only data between 0 and 359 will be sent
  26. int heading = meetAndroid.getInt();

  27. doSomethingUseful(heading);
  28. }
复制代码
目前看官方资料, 貌似除了上面的实现,也支持 android 机上去操作 arduino .

还有没有更好的方案? 对利用废旧 android 手机非常感兴趣! 原先个人是想拆解利用手机传感器,了解一圈以后感觉很困难。感觉 amarino 这个方案不错, 以后可以考虑收集 android 机做各种事了。

有兴趣的一起学习交流哈, 可以加我微信: hickwu --- 请注明 arduino-android , 也可在我 blog 留言交流: http://blog.hickwu.com/posts/282

hick: blog.HickWu.com  web开发者网站 噜吧: www.WebRube.com
分享到:
回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条