小编Bac*_*ave的帖子

Android + Arduino蓝牙数据传输

我可以通过蓝牙将我的Android应用程序连接到我的Arduino.但是,它们之间不能传输数据.以下是我的设置和代码:

HTC Android v2.2,蓝牙伴侣黄金调制解调器,Arduino Mega(ATmega1280)

Android Java代码:

package com.example.BluetoothExample;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.TextView;
import android.widget.EditText;  
import android.widget.Button;
import android.widget.Toast;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Set;
import java.util.UUID;

public class BluetoothExampleActivity extends Activity {
  TextView myLabel;
  EditText myTextbox;
  BluetoothAdapter mBluetoothAdapter;
  BluetoothSocket mmSocket;
  BluetoothDevice mmDevice;
  OutputStream mmOutputStream;
  InputStream mmInputStream;
  Thread workerThread;
  byte[] readBuffer;
  int readBufferPosition;
  int counter;
  volatile boolean stopWorker;

  @Override
  public void onCreate(Bundle savedInstanceState) { …
Run Code Online (Sandbox Code Playgroud)

android bluetooth arduino

21
推荐指数
2
解决办法
8万
查看次数

他们是如何编程第一个IDE的?

如果C用于编程Unix,用于在C中编程的是什么?等等,等等.他们是如何创建第一个程序的?

c

2
推荐指数
1
解决办法
1051
查看次数

标签 统计

android ×1

arduino ×1

bluetooth ×1

c ×1