You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
try to use USB Host Shield with a Bluetooth dongle in combination with one of those cheep mini bluetooth controllers for my e-skateboard
Almost there - by using the PS4BT example plus a few minor modifications:
want a fixed pairing. Just to one bluetooth address. Should not reconnect to something else. By adding the BT address to the main sketch and pass it through.
Want to to shutdown is slowly in case connection is lost. I was expecting that PS4BT.connected() will do that, but I need to include another boolen var connected and simply make it public to check. Done.
How to do it? It works 1st time when Arduino starts (or when I reset the board). But when I switch off and on again the controller it does not successfully re-connects. As I said, it does when its reboots.
Then I detected that its the same - it ONLY works when I initialized with
PS4BT PS4(&Btd, PAIR);
In contrast
PS4BT PS4(&Btd);
Does not work. Debug out is
HCI Disconnected from Device
Wait For Incoming Connection Request
Keyboard is connecting
Class of device: 000540
Incoming Connection Request
Remote Name: MOCUTE-036_B53-70E8
Connection established
Connected to Device: 16:07:15:03:70:E8
Received Key Request
Wait For Incoming Connection Request
HCI Disconnected from Device
Wait For Incoming Connection Request
Any idea?
Complete sketch:
/* 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>uint8_t bta[6] = {0xE8,0x70,0x03,0x15,0x07,0x16};
USB Usb;
//USBHub Hub1(&Usb); // Some dongles have a hub inside
BTD Btd(&Usb, bta); // 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;
voidsetup() {
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
#endifif (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start"));
while (1); // Halt
}
Serial.print(F("\r\nPS4 Bluetooth Library Started"));
}
voidloop()
{
Usb.Task();
//&& Btd.incomingPS4if (PS4.connected())
{
if (Btd.connected!=false)
{
Serial.print("Value: ");
Serial.println(PS4.getAnalogHat(LeftHatX));
}
}
}
The text was updated successfully, but these errors were encountered:
Hi,
try to use USB Host Shield with a Bluetooth dongle in combination with one of those cheep mini bluetooth controllers for my e-skateboard
Almost there - by using the PS4BT example plus a few minor modifications:
Open issue is reconnecting:
How to do it? It works 1st time when Arduino starts (or when I reset the board). But when I switch off and on again the controller it does not successfully re-connects. As I said, it does when its reboots.
Then I detected that its the same - it ONLY works when I initialized with
PS4BT PS4(&Btd, PAIR);
In contrast
PS4BT PS4(&Btd);
Does not work. Debug out is
Any idea?
Complete sketch:
The text was updated successfully, but these errors were encountered: