Hardware components | ||||||
![]() |
| × | 2 | |||
| × | 2 | ||||
![]() |
| × | 1 | |||
| × | 2 | ||||
| × | 1 | ||||
| × | 2 | ||||
| × | 1 | ||||
| × | 4 | ||||
Software apps and online services | ||||||
![]() |
| |||||
|
In this tutorial I have shown how anyone can convert a simple car to wireless remote controlled car that can be controlled by any PlayStation remote using some of the most common and easy-to-use components of electronics.
The use of PS2Xlib for Arduino IDE developed by Bill Porter makes it easier for us to to make use of any PlayStation remote control with some simple line of code!
Designs for the Chassis
This is the sketchup file for the designs of the various pats used for the making of the chassis of the car.
It contains one rectangular plate( 2 pieces will be required ), one C-shaped plate( 2 pieces will be required), one Caster wheel mount, and one small L-shaped bracket to attach the Caster wheel mount to the rectangular plate(2 pieces will be required).
It contains one rectangular plate( 2 pieces will be required ), one C-shaped plate( 2 pieces will be required), one Caster wheel mount, and one small L-shaped bracket to attach the Caster wheel mount to the rectangular plate(2 pieces will be required).
PS controller Transmitter
ArduinoThis piece of code is to be uploaded to the arduino board being used at the transmitter end
#include <PS2X_lib.h>
#include<SoftwareSerial.h>
SoftwareSerial mySerial(6,7); //HC-12 tx pin, rx pin
PS2X ps2x;
void setup() {
ps2x.config_gamepad(5,4,3,2, false, false); //GamePad(clock, command, attention, data, Pressures?, Rumble?)
Serial.begin(9600);
mySerial.begin(9600);
}
void moveForward(){
mySerial.println("1");
Serial.println("FORWARD");
}
void moveBackward(){
mySerial.println("2");
Serial.println("BACKWARD");
}
void turnRight(){
mySerial.println("3");
Serial.println("RIGHT");
}
void turnLeft(){
mySerial.println("4");
Serial.println("left");
}
void turnClockwise(){
mySerial.println("5");
Serial.println("clock");
}
void turnAnticlockwise(){
mySerial.println("6");
Serial.println("anticlock");
}
void loop() {
ps2x.read_gamepad();
int Ry=ps2x.Analog(PSS_RY); //Read the analog value up down movement from right joystick
delay(75);
int Rx=ps2x.Analog(PSS_RX); //Read the analog value right left movement from right joystick
delay(75);
int Ly=ps2x.Analog(PSS_LY); //Read the analog value up down movement from left joystick
delay(75);
int Lx=ps2x.Analog(PSS_LX); //Read the analog value right left movement from left joystick
delay(75);
if(Ly==0 && Ry==0){
moveForward();
}
if((Ly==255 || Ly==254) && (Ry==255 || Ry==255)){
moveBackward();
}
if(Ry==0 && Ly!=0){
turnRight(); //turn off left motor
}
if(Ly==0 && Ry!=0 ){
turnLeft(); //turn off right motor
}
if(Ly==0 && (Ry==255 || Ry==254)){
turnClockwise();
}
if((Ly==255 || Ly==254) && Ry==0){
turnAnticlockwise();
}
PS controller Receiver
ArduinoThis piece of code is to be uploaded to the arduino board at the receiver end.
#include<SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); //HC-12 tx pin, rx pin
int in1=4, in2=5, in3=6, in4=7; //Motor driver pins
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}
void moveForward(){
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
}
void moveBackward(){
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
}
void moveLeft(){
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
}
void moveRight(){
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}
void clockwise(){
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
}
void anticlockwise(){
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
}
void loop() {
if(mySerial.available()>0){
int input = mySerial.read();
if(input=='1'){
Serial.println("FORWARD");
moveForward();
}
if(input=='2'){
Serial.println("BACKWARD");
moveBackward();
}
if(input=='3'){
Serial.println("RIGHT");
moveRight();
}
if(input=='4'){
Serial.println("LEFT");
moveLeft();
}
if(input=='5'){
Serial.println("CLOCKWISE");
clockwise();
}
if(input=='6'){
Serial.println("ANTICLOCKWISE");
anticlockwise();
}
delay(190);
}
else{
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}
}
Comments
Please log in or sign up to comment.