background preloader

Project Arduino

Facebook Twitter

PSXLibrary. PSX Library This library allows an Arduino to interface with a standard digital Playstation 1 controller.

PSXLibrary

Installation is simple, just unzip the package into your Arduino Directory\hardware\libraries. Psx1.zip Use of the library is simple, only requiring an initialization, a setup, and then a read command. The included example shows a simple application of the library. The pinout for the Playstation controller is available at: Commands: Psx() Used to initialize the library Ex: Psx Psx; setupPins(dataPin, cmndPin, attPin, clockPin, delay) Defines which pins on the arduino are connected to the controller, as well as the delay on how long the clock remains high and low. Read() Reads the button data from the playstation controller, and returns it as an unsigned integer. The returned data is an unsigned integer, with each bit representing a specific button. Ex: if (data & psxUp) Each button is defined in the library, so there is no need to use hex codes when testing. Www.wegmuller.org/arduino/Arduino-Playstation_gameport.html. How to interface Arduino with a Playstation game-port controller A Playstation controller has two analog mini sticks (Dualshock and DualShock2 only), 12 pressure sensitive buttons (Dualshock 2 only) and two digital buttons.

www.wegmuller.org/arduino/Arduino-Playstation_gameport.html

All these inputs can be made available to the Arduino via only 4 pins (three of which can be shared with other functions, if planned carefully).Playstation controllers are cheap. There widely available (from brand new ones in stores to used ones at garage sales).Cordless versions make it easy to remote control your Arduino-based project.Very little external hardware is needed.I needed something to control this model excavator.

The Playstation gameport uses a rather sophisticated protocol built on top of a very simple and common serial interface: SPI. There is one difference between Arduino and a Playstation: while Arduino runs at 5V, the Playstation (and its peripherals) are designed to run at 3.3V. One item that may appear to be hard to get is a game-port connector. Sony Playstation (PSX) joystick controller port pinout and wiring. PSX controllers are intelligent devices and communicate with the Playstation device using a special syncrosound serial bus and protocol.

Sony Playstation (PSX) joystick controller port pinout and wiring

The controller system is implemented in bus architechture, which means that all signal wires are all tied together in PSX end (except select which is seperate for each device). PSX Signals descriptions: DATA Signal from Controller to PSX. This signal is an 8 bit serial transmission synchronous to the falling edge of clock (That is both the incoming and outgoing signals change on a high to low transition of clock. All the reading of signals is done on the leading edge to allow settling time.) COMMAND Signal from PSX to Controller. VCC VCC can vary from 5V down to 3V. ATT ATT is used to get the attention of the controller. CLOCK Signal from PSX to Controller. ACK Acknowledge signal from Controller to PSX. It should also be noted that this is a bus of sorts.

It is possible to adapt a joystick originally developed for PSX to a PC. Playstation Controller. #include <math.h>#include <stdio.h>#include <avr/io.h> #define LED_PIN 13#define DELAY(wait) digitalWrite(LED_PIN,LOW); delay(wait); digitalWrite(LED_PIN,HIGH); /* These are AVR PORTB pins, +8 to convert to Arduino pins */#define PS2clk 5#define PS2cmd 3#define PS2att 2#define PS2dat 4#define PS2PORT PORTB#define PS2IN PINB#define CTRL_CLK 20#define CTRL_BYTE_DELAY 20 //These are our button constants#define PSB_SELECT 0x01#define PSB_L3 0x02#define PSB_R3 0x04#define PSB_START 0x08#define PSB_PAD_UP 0x10#define PSB_PAD_RIGHT 0x20#define PSB_PAD_DOWN 0x40#define PSB_PAD_LEFT 0x80 #define PSB_L2 0x100#define PSB_R2 0x200#define PSB_L1 0x400#define PSB_R1 0x800#define PSB_GREEN 0x1000#define PSB_RED 0x2000#define PSB_BLUE 0x4000#define PSB_PINK 0x8000.

Playstation Controller