[英]How to Send Value from android app to Arduino Bluetooth HC-05
I am making an android app using android studio ,我正在使用 android studio 制作一个 android 应用程序,
I want to send value 'string or Integer' to arduino pro mini via bluetooth hc-05.我想通过蓝牙 hc-05 将值“字符串或整数”发送到 arduino pro mini。
The bluetooth hc-05 will already be connected (paired) to the android device .蓝牙 hc-05 已经连接(配对)到 android 设备。
Can you please help me to make a simple code that send the value via bluetooth?你能帮我做一个简单的代码,通过蓝牙发送值吗? Thank you so much.
非常感谢。
Well, the easiest way to implement that is to use a third-party library like this BluetoothLibrary .好吧,实现它的最简单方法是使用像这样的第三方库BluetoothLibrary 。
app module
gradle file.app module
gradle 文件中。ListView
and the logic to insert the discovered Bluetooth devices.ListView
和插入发现的蓝牙设备的逻辑来自己实现扫描功能。@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main)
bluetooth = new Bluetooth(this);
bluetooth.send("Your message");
}
DeviceCallback()
you will find its description in the Github repositoryDeviceCallback()
你会在 Github 存储库中找到它的描述You have to add some permissions in the Manifest files which are您必须在清单文件中添加一些权限
In order to give the access to your app to use the bluetooth为了允许访问您的应用程序以使用蓝牙
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.