質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Bluetooth

Bluetoothとは短距離の間でデータを交換するための無線通信規格である。固定・モバイル両方のデバイスから、短波の電波送信を行うことで、高いセキュリティをもつパーソナルエリアネットワーク(PAN)を構築する。

Arduino

Arduinoは、AVRマイコン、単純なI/O(入出力)ポートを備えた基板、C言語を元としたArduinoのプログラム言語と、それを実装した統合開発環境から構成されたシステムです。

Q&A

0回答

1897閲覧

USB_Host_Shield_2.0とBlueToothドングルを用いたArduinoとPS4互換コントローラーの接続

M101

総合スコア0

Bluetooth

Bluetoothとは短距離の間でデータを交換するための無線通信規格である。固定・モバイル両方のデバイスから、短波の電波送信を行うことで、高いセキュリティをもつパーソナルエリアネットワーク(PAN)を構築する。

Arduino

Arduinoは、AVRマイコン、単純なI/O(入出力)ポートを備えた基板、C言語を元としたArduinoのプログラム言語と、それを実装した統合開発環境から構成されたシステムです。

1グッド

0クリップ

投稿2021/05/04 01:10

編集2021/05/13 09:48

前提・実現したいこと

Arduino MEGAとDUALSHOCK4互換コントローラーBlueToothドングルUSB_Host_Shield_2.0のPS4BT.inoを用いて接続したいです.

発生している問題・エラーメッセージ

PS4BT.inoをBlueToothドングルを差し込んだArduinoに書き込んだのち,コントローラーのSHAREボタンとPSボタンを同時押しして初期接続モードに入り,シリアルモニタを確認したところ以下のようにメッセージが出ます.
しかしコントローラーは初期接続に失敗し(ずっと点滅したままで点灯にならない),ボタンを押しても何一つ反応がありません.

シリアルモニタ
あるサイトからお借りした画像ですが,自分の環境ではSend HID Control Request以下に続くはずのメッセージが表示されていません.
イメージ説明

該当のソースコード

PS4BT.inoのスケッチになります.(gitからダウンロードしたままのものです.)
PS4BT.hやPS4Parser.cpp, PS4Parser.h辺りを書き換える必要があるのかなと考えていますが,それがあってるのかもよくわかりません.

/* Example sketch for the PS4 Bluetooth library - developed by Kristian Lauszus For more information visit my blog: http://blog.tkjelectronics.dk/ or send me an e-mail: kristianl@tkjelectronics.com */ #include <PS4BT.h> #include <usbhub.h> // Satisfy the IDE, which needs to see the include statment in the ino too. #ifdef dobogusinclude #include <spi4teensy3.h> #endif #include <SPI.h> USB Usb; //USBHub Hub1(&Usb); // Some dongles have a hub inside BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so /* You can create the instance of the PS4BT class in two ways */ // This will start an inquiry and then pair with the PS4 controller - you only have to do this once // You will need to hold down the PS and Share button at the same time, the PS4 controller will then start to blink rapidly indicating that it is in pairing mode PS4BT PS4(&Btd, PAIR); // After that you can simply create the instance like so and then press the PS button on the device //PS4BT PS4(&Btd); bool printAngle, printTouch; uint8_t oldL2Value, oldR2Value; void setup() { Serial.begin(115200); #if !defined(__MIPSEL__) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection #endif if (Usb.Init() == -1) { Serial.print(F("\r\nOSC did not start")); while (1); // Halt } Serial.print(F("\r\nPS4 Bluetooth Library Started")); } void loop() { Usb.Task(); if (PS4.connected()) { if (PS4.getAnalogHat(LeftHatX) > 137 || PS4.getAnalogHat(LeftHatX) < 117 || PS4.getAnalogHat(LeftHatY) > 137 || PS4.getAnalogHat(LeftHatY) < 117 || PS4.getAnalogHat(RightHatX) > 137 || PS4.getAnalogHat(RightHatX) < 117 || PS4.getAnalogHat(RightHatY) > 137 || PS4.getAnalogHat(RightHatY) < 117) { Serial.print(F("\r\nLeftHatX: ")); Serial.print(PS4.getAnalogHat(LeftHatX)); Serial.print(F("\tLeftHatY: ")); Serial.print(PS4.getAnalogHat(LeftHatY)); Serial.print(F("\tRightHatX: ")); Serial.print(PS4.getAnalogHat(RightHatX)); Serial.print(F("\tRightHatY: ")); Serial.print(PS4.getAnalogHat(RightHatY)); } if (PS4.getAnalogButton(L2) || PS4.getAnalogButton(R2)) { // These are the only analog buttons on the PS4 controller Serial.print(F("\r\nL2: ")); Serial.print(PS4.getAnalogButton(L2)); Serial.print(F("\tR2: ")); Serial.print(PS4.getAnalogButton(R2)); } if (PS4.getAnalogButton(L2) != oldL2Value || PS4.getAnalogButton(R2) != oldR2Value) // Only write value if it's different PS4.setRumbleOn(PS4.getAnalogButton(L2), PS4.getAnalogButton(R2)); oldL2Value = PS4.getAnalogButton(L2); oldR2Value = PS4.getAnalogButton(R2); if (PS4.getButtonClick(PS)) { Serial.print(F("\r\nPS")); PS4.disconnect(); } else { if (PS4.getButtonClick(TRIANGLE)) { Serial.print(F("\r\nTriangle")); PS4.setRumbleOn(RumbleLow); } if (PS4.getButtonClick(CIRCLE)) { Serial.print(F("\r\nCircle")); PS4.setRumbleOn(RumbleHigh); } if (PS4.getButtonClick(CROSS)) { Serial.print(F("\r\nCross")); PS4.setLedFlash(10, 10); // Set it to blink rapidly } if (PS4.getButtonClick(SQUARE)) { Serial.print(F("\r\nSquare")); PS4.setLedFlash(0, 0); // Turn off blinking } if (PS4.getButtonClick(UP)) { Serial.print(F("\r\nUp")); PS4.setLed(Red); } if (PS4.getButtonClick(RIGHT)) { Serial.print(F("\r\nRight")); PS4.setLed(Blue); } if (PS4.getButtonClick(DOWN)) { Serial.print(F("\r\nDown")); PS4.setLed(Yellow); } if (PS4.getButtonClick(LEFT)) { Serial.print(F("\r\nLeft")); PS4.setLed(Green); } if (PS4.getButtonClick(L1)) Serial.print(F("\r\nL1")); if (PS4.getButtonClick(L3)) Serial.print(F("\r\nL3")); if (PS4.getButtonClick(R1)) Serial.print(F("\r\nR1")); if (PS4.getButtonClick(R3)) Serial.print(F("\r\nR3")); if (PS4.getButtonClick(SHARE)) Serial.print(F("\r\nShare")); if (PS4.getButtonClick(OPTIONS)) { Serial.print(F("\r\nOptions")); printAngle = !printAngle; } if (PS4.getButtonClick(TOUCHPAD)) { Serial.print(F("\r\nTouchpad")); printTouch = !printTouch; } if (printAngle) { // Print angle calculated using the accelerometer only Serial.print(F("\r\nPitch: ")); Serial.print(PS4.getAngle(Pitch)); Serial.print(F("\tRoll: ")); Serial.print(PS4.getAngle(Roll)); } if (printTouch) { // Print the x, y coordinates of the touchpad if (PS4.isTouching(0) || PS4.isTouching(1)) // Print newline and carriage return if any of the fingers are touching the touchpad Serial.print(F("\r\n")); for (uint8_t i = 0; i < 2; i++) { // The touchpad track two fingers if (PS4.isTouching(i)) { // Print the position of the finger if it is touching the touchpad Serial.print(F("X")); Serial.print(i + 1); Serial.print(F(": ")); Serial.print(PS4.getX(i)); Serial.print(F("\tY")); Serial.print(i + 1); Serial.print(F(": ")); Serial.print(PS4.getY(i)); Serial.print(F("\t")); } } } } } }

試したこと

BlueToothドングルとコントローラーの相性を確認するため,ノートPCにドングルを差してPC本体のBluToothを切って接続したところ,入力を確認できました.
またBlueTooth接続ではなくUSBを通して通信するPS4USB.inoも試してみましたが,やはりうまくいきませんでした.

補足情報(FW/ツールのバージョンなど)

Arduino IDEを使って書き込みを行っています.Arduinoを使うのもほとんど初めてなのでよくわかっていないことだらけです.

otaka👍を押しています

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問