Project tutorial
PS3 Controller Control Servo Wireless

PS3 Controller Control Servo Wireless

This project will show you how to connect PS3 controller to your Arduino wirelessly to control a 180 degrees servo.

  • 23,054 views
  • 3 comments
  • 14 respects

Components and supplies

About this project

Please respect the project and follow me.

Step #1

Put the USB Shield on the top of the Arduino.

Step #2

Upload the code to your Arduino.


#include <SPI.h>
#include <PS3BT.h>                                                    //Include the necessary libraries.

#include <Servo.h>

USB Usb;

BTD Btd(&Usb);

PS3BT PS3(&Btd);



Servo servo1;                                                         //Create instances of type Servo. servo1 is the steering servo and servo2 is the ESC.

Servo servo2;



void setup() {

   Serial.begin(115200);

  

   if (Usb.Init() == -1) {

    Serial.print(F("\r\nOSC did not start"));

    while (1); //halt

  }

  Serial.print(F("\r\nPS3 Bluetooth Library Started"));



  servo1.attach(9);                                                  //Steering servo on digital pin 5

}

void loop()

{

  Usb.Task();



  if (PS3.PS3Connected || PS3.PS3NavigationConnected) {

  

    servo1.write(map(PS3.getAnalogHat(RightHatX), 0, 255, 0, 180));

    servo2.write(map(PS3.getAnalogHat(LeftHatY), 0, 255, 180, 0));

    Serial.println(map(PS3.getAnalogHat(RightHatX), 0, 255, 0, 180));

  }

  if (PS3.getButtonClick(UP)) {

    digitalWrite(Led, HIGH);



    Serial.print(F("\r\nUp"));



     if (PS3.PS3Connected) {

      PS3.setLedOff();

      PS3.setLedOn(LED1);



    }

  }

}

Step #3

Plug the Bluetooth dongle in the USB shield.


Final Step

open the serial and wait until the Arduino will read the Bluetooth dongle then unplug it and connect your PS3 control to the USB shield and wait until the Arduino will change the mac address of the PS3 controller then unplug it an plug the Bluetooth dongle again and press the center button in the PS3 controller (HOME BUTTON(power on)) and the PS3 will be connected by seeing the number 1 on the controller is on. and on the serial it will tell you that the PS3 controller is connected and ready to use. then the angle of the servo will be showing in the serial.

Enjoy. Please Respect this project and follow me Youssef Emad. :-)

Code

ps3_cont._robot.inoC/C++
#include <SPI.h>
#include <PS3BT.h>                                                    //Include the necessary libraries.
#include <Servo.h>
USB Usb;
BTD Btd(&Usb);
PS3BT PS3(&Btd);

Servo servo1;                                                         //Create instances of type Servo. servo1 is the steering servo and servo2 is the ESC.
Servo servo2;

void setup() {
   Serial.begin(115200);
  
   if (Usb.Init() == -1) {
    Serial.print(F("\r\nOSC did not start"));
    while (1); //halt
  }
  Serial.print(F("\r\nPS3 Bluetooth Library Started"));

  servo1.attach(9);                                                  //Steering servo on digital pin 5
}
void loop()
{
  Usb.Task();

  if (PS3.PS3Connected || PS3.PS3NavigationConnected) {
  
    servo1.write(map(PS3.getAnalogHat(RightHatX), 0, 255, 0, 180));
    servo2.write(map(PS3.getAnalogHat(LeftHatY), 0, 255, 180, 0));
    Serial.println(map(PS3.getAnalogHat(RightHatX), 0, 255, 0, 180));
  }
  if (PS3.getButtonClick(UP)) {
    digitalWrite(Led, HIGH);

    Serial.print(F("\r\nUp"));

     if (PS3.PS3Connected) {
      PS3.setLedOff();
      PS3.setLedOn(LED1);

    }
  }
}

Comments

Similar projects you might like

Servo Control with TV Remote Control

Project showcase by eldo85

  • 5,594 views
  • 5 comments
  • 17 respects

Bluetooth control led with lcd led status display real time.

Project tutorial by Youssef Sabaa

  • 17,292 views
  • 4 comments
  • 34 respects

Temperature Sensor To control Servo Motor

by Jasleen

  • 6,407 views
  • 2 comments
  • 10 respects

Servo Control Panel

Project tutorial by dancili

  • 1,202 views
  • 0 comments
  • 6 respects
Add projectSign up / Login