eclipse 如何创建一个 Android 应用程序来通过 Wi-Fi 控制 Arduino?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9832481/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 17:52:25  来源:igfitidea点击:

How to create an Android app to control Arduino over Wi-Fi?

androideclipsearduinoadk

提问by Anish

I have an Arduino Mega board. I've connected the WiFlymodule to it and established connection with my Android phone. Now I want to make a simple app for my Android, where I press a button and the LEDon the Arduino board turns on.

我有一个 Arduino Mega 板。我已经将WiFly模块连接到它并与我的 Android 手机建立了连接。现在我想为我的 Android 制作一个简单的应用程序,我按下一个按钮,Arduino 板上的LED 就会亮起

In fact, I've already made an app (in Eclipse) with a button, and if I press it, I get a toast message saying the button is pressed. Now, how do I implement the Wi-Fifunctionality to it and enable it to light up the Arduino's LED?

事实上,我已经制作了一个带有按钮的应用程序(在 Eclipse 中),如果我按下它,我会收到一条消息,说按钮被按下了。现在,我该如何实现Wi-Fi功能并让它点亮 Arduino 的 LED?

回答by slayton

It really depends on the types of inputs the Arduino board is expecting. What do the Arduino documentation say about communication over a Wi-Fi connection? I imagine reading those would be a good place to start.

这实际上取决于 Arduino 板所期望的输入类型。Arduino 文档对通过 Wi-Fi 连接进行的通信有什么看法?我想阅读这些将是一个很好的起点。

It looks like you communicate with the Arduino via HTTP. This makes things really easy. One quick way you might do this (I haven't tested this) is to do something like the following:

看起来您通过HTTP与 Arduino 通信。这让事情变得非常容易。您可以执行此操作的一种快速方法(我尚未测试过)是执行以下操作:

URL url = new URL(arduinoCommandURl);
InputStream is = new InputStreamReader(url.openStream(), "UTF-8"));
is.read();

回答by matthew

To avoid re-inventing the wheel, take a look at www.pfod.com.au, which has a general purpose Android app to control micro devices via bluetooth or wifi with optional 128 bit security. Control via SMS is under development. What is displayed on your mobile is completely determined by the micro code. No Android coding required at all.

为避免重新发明轮子,请查看www.pfod.com.au,它有一个通用的 Android 应用程序,可通过蓝牙或 wifi 控制微型设备,并具有可选的 128 位安全性。通过 SMS 的控制正在开发中。您手机上显示的内容完全由微码决定。根本不需要Android编码。

Lots of example projects and a free pfodDesigner app which lets you design your own menus and then generates the Arduino code for you that will display the menu on the pfodApp. The one pfodApp handles every menu you design. No Android coding required.

许多示例项目和一个免费的 pfodDesigner 应用程序,它可以让您设计自己的菜单,然后为您生成 Arduino 代码,将在 pfodApp 上显示菜单。一个 pfodApp 处理您设计的每个菜单。无需 Android 编码。

pfodApp will also capture and plot data send from your micro in CSV format. Again the plots are controlled completely by the code in your micro. No changes needed in the pfodApp.

pfodApp 还将以 CSV 格式捕获和绘制从您的微型发送的数据。同样,绘图完全由您的 micro.js 中的代码控制。pfodApp 中无需更改。