[Module]HC-05(06)Bluetoothを選択しますが、HC-05(06)Bluetoothモジュールは技適製品でありません。
代替品にRN-42 Bluetooth無線モジュールを使って操作してみました。
●RN-42 Bluetooth無線モジュール(技適製品)
販売元:秋月電子通商【https://akizukidenshi.com/catalog/g/g107378/】
●RN-42Bluetoothバージョン2.0、1.2、1.1と下位互換
(HC-05(06)Bluetooth バージョン2.0)
●同ブログ関連記事:【RemoteXY使い方】
①RN-42使用 Bluetooth無線モジュール評価キット
Lを点灯 |
※通信ボーレートをRemoteXY SERIAL_SPEED 9600に合わせる
DIPスイッチ(S1) 1~3 = OFF / 4 = ON (115200 → 9600bps)
②RN-42 Bluetooth 2mmピッチ変換モジュール
通信ボーレートをRemoteXY SERIAL_SPEED 9600に合わせる
抵抗3.3KΩをIO7とVDD(3.3V)に接続する。(115200 → 9600bps)
●同ブログ関連記事:
分電圧
Arduino Nano(5V)
RN-42(3.3V)
チップ抵抗2KΩ +1KΩ
左:GND
中 : RX(3.3V)
右 : TX(5V)
回路図
【Properties】【Configuration】設定変更
[Connection]Bluetooth
[Board]Arduino Nano
[Module]HC-05(06)Bluetooth
【Apply】実行
【Button】をスマホ画面に貼付け形・色・文字を入力
作成したら。
プログラム
//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// you can enable debug logging to Serial at 115200
//#define REMOTEXY__DEBUGLOG
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__SOFTSERIAL
#include <SoftwareSerial.h>
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_SERIAL_RX 2
#define REMOTEXY_SERIAL_TX 3
#define REMOTEXY_SERIAL_SPEED 9600
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] = // 34 bytes
{ 255,2,0,0,0,27,0,16,96,1,1,1,5,17,24,23,135,8,79,32,
78,0,1,1,34,17,24,23,135,8,79,70,70,0 };
// this structure defines all the variables and events of your control interface
struct {
// input variables
uint8_t button_1; // =1 if button pressed, else =0
uint8_t button_2; // =1 if button pressed, else =0
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
void setup()
{
RemoteXY_Init ();
pinMode(13, OUTPUT);
}
void loop()
{
RemoteXY_Handler ();
if(RemoteXY.button_1 == 1)digitalWrite(13, HIGH);
if(RemoteXY.button_2 == 1)digitalWrite(13, LOW);
}
0 件のコメント:
コメントを投稿