Project tutorial
Atari PS3 controller

Atari PS3 controller © GPL3+

Dump that retro joystick and join the 21st Century.

  • 113 views
  • 0 comments
  • 0 respects

Components and supplies

About this project

Overview

This tutorial shows the steps required to attach a PS3 controller to an Atari 8-bit home computer

Introduction

The standard Atari joystick can't be beaten for the full on retro gaming experience. Or can it? Controller technology has moved on a bit in the last 35 years. How hard is it to use a PS3 contoller? Will my pet human still suck at Defender?

There's two sides to this; reading the PS3 controller and then telling the Atari what's going on.

The idea here is that the old Atari joystick works by switching on whatever pins correspond to a movement in a particular direction.

All we need to do is replicate this with the Arduino using digitalWrite. Reading the PS3 controller is done by the USB shield.

If anyone's getting a sense of deja vu about this, it's the same technology as the optical mouse tutorial

https://www.instructables.com/id/Atari-8-Bit-Optic...

Supplies:

Arduino Uno

Arduino USB shield

Wires. I'm using Dupont connectors as they plug straight into the USB shield

PS3 controller

Female 9 pin D connector

Atari 8-bit computer. I'm using an 800 XL but I expect it to work with anything with a suitable joystick port. It'd be interesting to know if it works with a video consol...

Step 1: Attach the USB Shield

Mount the USB shield on the Arduino as shown in the image. That's it!

During the initial development stages of the Optical Mouse tutorial I tried a cheap knock-off USB shield from Ebay and some other piece of junk from Hobbytronics. Learn from my mistakes; buy the proper components. They might cost a few pounds/dollars more but you save so much aggravation.

Step 2: Program the Arduino

I'm assuming that you know how to program an Arduino. If not, learn! It's a great micro processor and your life will be much better. There's tons of support on the internet, and

https://www.arduino.cc/ is the starting point.

The Arduino Code is attached. I'm going to own up to some 'standing on the shoulders of giants' and not claim this as all my own work. I just hacked a demo file a bit.

You'll also need some librarieshttps://github.com/felis/USB_Host_Shield_2.0

https://www.arduinolibraries.info/libraries/usb-h....

Also take a look at this site

https://www.arduinolibraries.info/libraries/usb-h....

The Atari is a bit slower than the Arduino so the code reduces the sensitivity of the joystick movement and delays the main loop by 15ms. I'm only using the left stick, L2 and R2, but the other PS3 controller buttons and sticks are available with a tiny bit of re-coding.

There are a few limiting factors.

The old Atari joystick is the first as it only has movement and a fire button, so unlike modern controllers, we can't have too many tricks.

I haven't used the PS3 controller shakers; I don't know how much current they draw and there's a risk of damaging the PIA in the Atari. Experiment at your own risk!

Step 3: Add Some Wires

Using the Dupont wires,

connect Arduino pin 3 to pin 6 on the Atari

connect Arduino pin 4 to pin 1 on the Atari

connect Arduino pin 5 to pin 2 on the Atari

connect Arduino pin 6 to pin 3 on the Atari

connect Arduino pin 7 to pin 4 on the Atari

Now plug in the PS3 controller

Done!

Step 4: Further Development

I haven't included it, but you could change the Arduino code to have auto fire, use the right stick, or the buttons.

The USB shield doesn't only work with PS3 controllers. You can also plug in other game controllers, USB storage, optical mice, blue tooth dongles, all of which could then be added to your Atari...

https://store.arduino.cc/arduino-usb-host-shield

https://www.instructables.com/id/Atari-8-Bit-Optic...

A further thought. I'm using an Atari 8-bit computer because it's the best, but if you bought a C64 or Vic 20 by mistake it'd probably work with them as well.

Code

Atari_PS3_joystick.inoC/C++
// USB_Host_Shield_2.0 - Version: Latest 
#include <PS3USB.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;
/* You can create the instance of the class in two ways */
PS3USB PS3(&Usb); // This will just create the instance
//PS3USB PS3(&Usb,0x00,0x15,0x83,0x3D,0x0A,0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch

bool printAngle;
uint8_t state = 0;

int firepin = 3;
int uppin = 4;
int downpin = 5;
int leftpin = 6;
int rightpin = 7;

void setup() {
   Serial.begin(9600);
#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\nPS3 USB Library Started"));

  pinMode(firepin, OUTPUT);
  pinMode(uppin, OUTPUT);
  pinMode(downpin, OUTPUT);
  pinMode(leftpin, OUTPUT);
  pinMode(rightpin, OUTPUT);
}   

void reset ()
{
// reset pins
  digitalWrite(firepin, HIGH);
  digitalWrite(uppin, HIGH);
  digitalWrite(downpin, HIGH);
  digitalWrite(leftpin, HIGH);
  digitalWrite(rightpin, HIGH);
  
}

void loop() 
{
  Usb.Task();

  if (PS3.PS3Connected || PS3.PS3NavigationConnected) 
  {
  // Left (left stick)
  if (PS3.getAnalogHat(LeftHatX) < 80 )
    {
      Serial.print(F("\r\nLeftHatX: Left "));
      digitalWrite(leftpin, LOW);
      }
      
  // Right (left stick)
  if (PS3.getAnalogHat(LeftHatX) > 175) 
{
      Serial.print(F("\r\nLeftHatX: Right"));
      digitalWrite(rightpin, LOW);
}

// Down (left stick)
  if   (PS3.getAnalogHat(LeftHatY) > 175)
  {
      Serial.print(F("\r\nLeftHatY: Down"));
      digitalWrite(downpin, LOW);    
  }
// Up (left stick)
  if( PS3.getAnalogHat(LeftHatY) < 80)
    {
      Serial.print(F("\r\nLeftHatY: Up"));
      digitalWrite(uppin, LOW);       
  }

// right (right stick)  
 if (PS3.getAnalogHat(RightHatX) > 175)
 {
  // enter code here
 }

// left (right stick)
  if (PS3.getAnalogHat(RightHatX) < 80)
  {
    //enter code here
  }

// down (right stick)
  if (PS3.getAnalogHat(RightHatY) > 175)
  {
    // enter code here
  }
// up (right stick)
  if ( PS3.getAnalogHat(RightHatY) < 80) 
{
  // enter code here  
}
  

  // Analog button values can be read from almost all buttons
    if (PS3.getAnalogButton(L2) )
    {
      Serial.print(F("\r\nL2: "));
      digitalWrite(firepin, LOW);
    }
              
    if (PS3.getAnalogButton(R2)) 
    {
      Serial.print(F("\r\R2: "));
      digitalWrite(firepin, LOW);

      }

    delay(15);
    reset();
    
  }
}

void notused()
{
  /*
    if (PS3.getButtonClick(PS))
      Serial.print(F("\r\nPS"));

    if (PS3.getButtonClick(TRIANGLE))
      Serial.print(F("\r\nTriangle"));
    if (PS3.getButtonClick(CIRCLE))
      Serial.print(F("\r\nCircle"));
    if (PS3.getButtonClick(CROSS))
      Serial.print(F("\r\nCross"));
    if (PS3.getButtonClick(SQUARE))
      Serial.print(F("\r\nSquare"));

    if (PS3.getButtonClick(UP)) {
      Serial.print(F("\r\nUp"));
      PS3.setLedOff();
      PS3.setLedOn(LED4);
    }
    if (PS3.getButtonClick(RIGHT)) {
      Serial.print(F("\r\nRight"));
      PS3.setLedOff();
      PS3.setLedOn(LED1);
    }
    if (PS3.getButtonClick(DOWN)) {
      Serial.print(F("\r\nDown"));
      PS3.setLedOff();
      PS3.setLedOn(LED2);
    }
    if (PS3.getButtonClick(LEFT)) {
      Serial.print(F("\r\nLeft"));
      PS3.setLedOff();
      PS3.setLedOn(LED3);
    }

    if (PS3.getButtonClick(L1))
      Serial.print(F("\r\nL1"));
    if (PS3.getButtonClick(L3))
      Serial.print(F("\r\nL3"));
    if (PS3.getButtonClick(R1))
      Serial.print(F("\r\nR1"));
    if (PS3.getButtonClick(R3))
      Serial.print(F("\r\nR3"));

    if (PS3.getButtonClick(SELECT)) {
      Serial.print(F("\r\nSelect - "));
      PS3.printStatusString();
    }
    if (PS3.getButtonClick(START)) {
      Serial.print(F("\r\nStart"));
      printAngle = !printAngle;
    }
    if (printAngle) {
      Serial.print(F("\r\nPitch: "));
      Serial.print(PS3.getAngle(Pitch));
      Serial.print(F("\tRoll: "));
      Serial.print(PS3.getAngle(Roll));
    }
  }
  else if (PS3.PS3MoveConnected) { // One can only set the color of the bulb, set the rumble, set and get the bluetooth address and calibrate the magnetometer via USB
    if (state == 0) {
      PS3.moveSetRumble(0);
      PS3.moveSetBulb(Off);
    } else if (state == 1) {
      PS3.moveSetRumble(75);
      PS3.moveSetBulb(Red);
    } else if (state == 2) {
      PS3.moveSetRumble(125);
      PS3.moveSetBulb(Green);
    } else if (state == 3) {
      PS3.moveSetRumble(150);
      PS3.moveSetBulb(Blue);
    } else if (state == 4) {
      PS3.moveSetRumble(175);
      PS3.moveSetBulb(Yellow);
    } else if (state == 5) {
      PS3.moveSetRumble(200);
      PS3.moveSetBulb(Lightblue);
    } else if (state == 6) {
      PS3.moveSetRumble(225);
      PS3.moveSetBulb(Purple);
    } else if (state == 7) {
      PS3.moveSetRumble(250);
      PS3.moveSetBulb(White);
    }
   
   */
}
Github
https://github.com/felis/USB_Host_Shield_2.0

Comments

Similar projects you might like

Mega Bread - Atari Joystick Linking for Robotics Control

Project in progress by Pigeon-Kicker

  • 1,955 views
  • 3 comments
  • 10 respects

Arduino Nano: Control 2 Stepper Motors With Joystick

Project tutorial by Boian Mitov

  • 15,033 views
  • 5 comments
  • 38 respects

Joystick Controller for MeArm Robot - Recording Coordinates

Project tutorial by utilstudio

  • 7,402 views
  • 6 comments
  • 27 respects

MeArm 1.6.1 Robot Joystick Board Recording Movements (IR)

Project tutorial by utilstudio

  • 4,593 views
  • 2 comments
  • 15 respects

Etch A Sketch Joystick

Project tutorial by millerman4487

  • 3,566 views
  • 2 comments
  • 19 respects

Atari 65XE as USB-Keyboard

Project tutorial by iot4c

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