如何在没有无线模块的情况下让Android和Arduino进行通信

发布于 2024-11-09 21:39:17 字数 431 浏览 2 评论 0原文

我开发了一个 Arduino 应用程序,在其中我可以通过串行监视器控制 LED 13。

也就是说,

  • 如果我在串行监视器中键入 0,则引脚 13 处的 LED 会亮起;
  • 如果我在串行监视器中键入 1,则 LED 会熄灭。

现在我想用我的 Android 手机来完成这一切。 我遇到的问题是:

  • 首先,如何创建一个 PHP 服务器来解决所有这些问题
  • 如何在我的 Android 设备上打开本地主机,使其像本地服务器一样
  • 如何使服务器与串行交互port

我并不要求所有的代码和项目,只是给我指明方向,我就可以了。

I have developed an Arduino application in which I can control LED 13 via a serial monitor.

That is,

  • if I type 0 in a serial monitor LED at pin 13 lights up and
  • if I type 1 in a serial monitor the LED lights off.

Now I want to do all this with my Android phone.
The issues I have are:

  • How to, first of all, create a PHP server for getting all this worked out
  • How to open up the localhost on my Android device so that it acts like a local server
  • How to make the server interact with the serial port

I am not asking for all the code and project but just show me the way, and I will be all right.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

惟欲睡 2024-11-16 21:39:17

大多数 Android 和 Arduino 设备在直接“开箱即用”时无法相互通信 - 需要添加硬件和/或系统软件修改。

您有多种选择

0) 蓝牙相当干净,现在价格在 20 美元范围内,因此它既是最具成本效益的选择之一,也是最不可能冒损坏手机硬件风险的选择之一 - 但您说您不想要那。

1)部分手机(例如G1)具有低压串口,可以通过[root并]安装定制内核来启用。您将需要电平转换电路作为arduino的输出电压,而低电压仍然太高而手机无法处理。您还需要通过修改完整的耳机适配器或从 Sparkfun 等地方获取特殊的 HTCUSB 连接器。

2) 有些手机可以通过 [root 并] 安装自定义内核来充当 USB 主机。它们不提供 USB 总线电源,但使用 arduino,您可以将所有内容公开,因此连接单独的电源应该相当简单。最近的一些平板电脑具有开箱即用的 USB 主机模式。 编辑:在更高版本的 Android 中,可能会提供非 root USB 主机 API 和 USB 总线电源,但这会因型号而异并且不一致

3)您可以在arduino上使用USB主机扩展板,如果设备运行Android 2.3.4或更高版本,请使用Gooogle的官方ADK 协议与 Android 设备上的软件对话;如果 Android 版本较早,则有一些非官方项目可以使用 ADB 协议,并且应该适用于大多数设备(可能需要进行一些小的修改)。两者都被设计为保留在 Android 设备上的非特权用户空间中 - 无需 root,无需修改内核。

4) 您可以构建一个低波特率调制解调器,并使用 Android 端的软件调制解调器通过其耳机插孔与 Android 设备通信。

5)你可以在arduino上放一个无线以太网扩展板

Most Android and Arduino devices cannot talk to each other when straight "out of the box" - add on hardware and/or system software modifications are required.

You have a variety of choices

0) Bluetooth is fairly clean and now in the $20 range, so it's both one of the most cost effective choices and one of the least likely to risk damaging the phone hardware - but you said you don't want that.

1) Some phones such as the G1 have low-voltage serial ports which can be enabled by [rooting and] installing a customized kernel. You will need level translation circuitry as the output voltage of the arduino while low is still too high for the phone to handle. You will also need to source a special HTCUSB connector, either by modifying the full headset adapter or getting it from someplace like sparkfun.

2) Some phones can function as usb hosts by [rooting and] installing a customized kernel. They do not supply usb bus power, but with an arduino you have everything out in the open so cabling up a separate supply should be fairly simple. A few recent tablets have usb host mode out of the box. Edit: with later Android versions, a non-root USB host API and USB bus power may be available, but this varies by model and has been inconsistent.

3) You can use a USB host shield on the arduino, and if the device runs Android 2.3.4 or later use Gooogle's official ADK protocol to talk to software on the android device; if the android version is earlier, there are unofficial projects which talk the ADB protocol and should work with most devices (perhaps with small modifications). Both are designed to remain within unprivileged userspace on the android device - no rooting, no kernel modifications.

4) You could build a low-baud-rate modem and talk to the android device through its headset jack, using a software modem on the android side.

5) You could put a wireless ethernet shield on the arduino

缺⑴份安定 2024-11-16 21:39:17

我个人没有使用 Arduino 的经验。但是 Cellbots 的人有许多项目使用 Android 手机作为小型机器人的大脑,他们使用 Arduino他们中的大多数。一切都是开源的,您也许能够找到对您有帮助的示例。

I have no experience with Arduino personally. But the guys over at Cellbots have many projects that use Android phones as the brain for small robots and they use Arduino in most of them. Everything is open sourced, and you might be able to find examples that will help you out there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文