それで、最近私はこれらの一連のチュートリアルに従っています http://www.youtube.com/playlist?list=PL2cK5QO_pN1gfEcWZ8tCWUb-WyxAiMyIK Bluetooth モジュール HC-05 を使用して Arduino と Android を接続するには
私は彼のスキームを正確に実行しました.Bluetoothモジュールは私のAndroidでHC-05として検出されましたが、ペアリングされません. 赤い LED が点滅し続けます。http://mcuoneclipse.com/2013/06/19/using-the-hc-06-bluetooth-module/のよう に、モジュールの赤い LED はステータスを示します: 点滅: ペアリングの準備ができています 点灯: ペアリング済み
これは、デバイス名の横に「(Paired)」という出力を取得するコードです
receiver = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action)){
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
devices.add(device);
String s = "";
for(int a=0;a<pairedDevices.size();a++){
if (device.getName().equals(pairedDevices.get(a))){
//append
s = "(Paired)";
break;
}
}
listAdapter.add(device.getName()+" "+s+" "+"\n"+device.getAddress());
}else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)){
}else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)){
}else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)){
if (btAdapter.getState() == btAdapter.STATE_OFF){
turnOnBT();
}
}
}
};
代わりに、デバイスがペアリングされていないというトーストメッセージが表示されました
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
if (btAdapter.isDiscovering()){
btAdapter.cancelDiscovery();
}
if (listAdapter.getItem(arg2).contains("(Paired)")){
BluetoothDevice selectedDevice = devices.get(arg2);
ConnectThread connect = new ConnectThread(selectedDevice);
connect.start();
}else {
Toast.makeText(getApplicationContext(), "device is not paired", 0).show();
}
}
私は何を取りこぼしたか?注:私は、2つのチップを備えた外部電源モジュールHC-05を使用しています(ビデオでは1つのチップしかありません)Arduino UNO(ビデオではAndroid Pro Miniを使用)