Serial.print(F("\r\nPS4 Bluetooth Library Started")) Serial.print(F("\r\nOSC did not start"))
While (!Serial) // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection After that you can simply create the instance like so and then press the PS button on the device 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
This will start an inquiry and then pair with the PS4 controller - you only have to do this once * You can create the instance of the PS4BT class in two ways */ USBHub Hub1(&Usb) // Some dongles have a hub insideīTD Btd(&Usb) // You have to create the Bluetooth Dongle instance like so Int IN4 = 6 //control pin for second motor Int IN3 = 5 //control pin for second motor Int IN2 = 4 //control pin for first motor Int IN1 = 3 //control pin for first motor Satisfy the IDE, which needs to see the include statement in the ino too. If you are using a different version of Arduino, then you can simply follow the pinout below for wiring it to your own Arduino board.
For this project, we will be adapting this code for controlling the motor of an Arduino Robot car using the left joystick of a PS4 controller. The example sketch also shows how easy it is to add a PS4 controller into your own Arduino project. All of the source code is available on Github. Now either load up a game, or on Windows press 'Win + R' to run a command and type in 'joy.cpl' This is Windows built-in joystick utility, select the 'Keyboard/Mouse/Joystick' and press 'Properties' now we will see live input from our custom game controller Exciting stuff. If you want to experiment more with the USB Host by yourself, ’s work could be helpful to get started. And once the Bluetooth connection is established with the PS4 controller, we can use simple functions to read the state of the device.Īlso, all of the code is open source. Then you can use the included library to pair with the Bluetooth based PS4 controller. The USB shield is necessary because we need to connect a Bluetooth based PS4 Controller to the Arduino, which doesn’t have a Bluetooth receiver. You can utilize Sparkfun’s USB shield instead. I used the USB host shield from Arduino but it’s now discontinued. To get this project working, you will need the USB Host Shield for the Arduino and a Bluetooth dongle.
Max Current: 400mA only when Arduino is powered from its USB port.Max Current: 500mA only when Arduino is connected with a good power supply.USB Host 5V/500mA supply for USB protocol.