////////////////////////////////////////////////////////////////////////////////// DEBUGGING/////////////////////////////////////////////////////////////////////////////////* Set this to 1 to activate serial debugging */#define ENABLE_UHS_DEBUGGING 1
Bluetooth ドングルを USB ホストシールドに挿し、Arduino と合体させておく。
[ファイル | スケッチ例 | USB Host Shield Library 2.0 | Bluetooth | PS3BT] を開く。
そのままコンパイルして Arduino へ転送する。
念のためにリセットボタンを押して Arduino を再起動する。
シリアルモニタを開く (115200 bps)。
xx:xx:xx:xx:xx:xx の部分に表示されている Bluetooth Address を控えておく。もし、OSC did not start と表示されたら、ジャンパーをブリッジしていないか、対応していない Bluetooth ドングルだと思われる。
PS3 Bluetooth Library Started
Bluetooth Dongle Initialized
No response to HCI Reset
HCI Reset complete
Write class of device
Local Bluetooth Address: xx:xx:xx:xx:xx:xx
Wait For Incoming Connection Request
スケッチを書き換える。PS3BT の上の行をコメントアウトで止めて、下の行をアンコメントし、6 つの 16進値を先程控えておいた Bluetooth Address で書き換える。
/* You can create the instance of the class in two ways *///PS3BT PS3(&Btd); // This will just create the instance<- この行をコメントアウト
PS3BT PS3(&Btd, 0x00, 0x15, 0x83, 0x3D, 0x0A, 0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch<- この行をアンコメントして編集
// Just a copy of the HelloWorld example bundled with the LiquidCrystal library in the Arduino IDE// HD44780 compatible LCD display via MAX3421E GPOUT support header// pinout: D[4-7] -> GPOUT[4-7], RS-> GPOUT[2], E ->GPOUT[3]#include <max_LCD.h>// Satisfy IDE, which only needs to see the include statment in the ino.#ifdef dobogusinclude#include <spi4teensy3.h>#include <SPI.h>#endif
USB Usb;
Max_LCD lcd(&Usb);
void setup() {
Usb.Init();// <- これを追加// Set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Hello, World!");
}
void loop() {
// Set the cursor to column 0, line 1 (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// Print the number of seconds since reset:
lcd.print(millis() / 1000);
}
ちなみに USB Host Shield Library v1.0 だとこんなスケッチで動作します。一見関係なさそうな Usb.h をインクルードし、Usb オブジェクトを用意しないと動作しません...インクルードしなくてもコンパイルエラーにはならないのに。
// Just a copy of the HelloWorld example bundled with the LiquidCrystal library in the Arduino IDE// HD44780 compatible LCD display via MAX3421E GPOUT support header// pinout: D[4-7] -> GPOUT[4-7], RS-> GPOUT[2], E ->GPOUT[3]#include <Max_LCD.h>#include <Usb.h>
USB Usb;
Max_LCD lcd;
void setup() {
// Set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Hello, World!");
}
void loop() {
// Set the cursor to column 0, line 1 (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// Print the number of seconds since reset:
lcd.print(millis() / 1000);
}