-
Notifications
You must be signed in to change notification settings - Fork 226
Description
It might be nice to add links to projects and the protocol.
I found a good page on the protocol here:
and
There are several projects listed on Bill Porter's post here:
http://www.billporter.info/2010/06/05/playstation-2-controller-arduino-library-v1-0/
That post had this list:
Hey guys, feel free to drop a link off in the comments to your project that uses my library. I’ll post it here.
Guitar Hero Axe Controlled Flamethrowers by Chris Marion
Scanalogic Review by CuriousInventor
SAGAR by Me
Remote Controlled Robot (Video) by ‘teachengineering‘
‘America Dream’ Electric Hammock by Stephen Shaffer
Life size R2D2 robot by Dan
Simon Says via DDR mat by Dalpix
I later found this instructable by Oswadonfire/chismarion.net about FireHero which seems related to the broken Guitar Hero Axe Controlled Flamethrowers link. It has the code below:
// FireHero_1_0.pde code from
// https://www.instructables.com/FireHero-Turn-Guitar-Hero-into-an-extreme-sport-b/
#include <PS2X_lib.h>
#define FlameEffect1 1
#define FlameEffect2 2
#define FlameEffect3 3
#define FlameEffect4 4
#define FlameEffect5 5
PS2X ps2x; // create PS2 Controller Class
//right now, the library does NOT support hot pluggable controllers, meaning
//you must always either restart your Arduino after you conect the controller,
//or call config_gamepad(pins) again after connecting the controller.
int error = 0;
byte type = 0;
byte vibrate = 0;
void setup(){
pinMode(FlameEffect1, OUTPUT);
pinMode(FlameEffect2, OUTPUT);
pinMode(FlameEffect3, OUTPUT);
pinMode(FlameEffect4, OUTPUT);
pinMode(FlameEffect5, OUTPUT);
Serial.begin(57600);
error = ps2x.config_gamepad(13,11,10,12); //setup GamePad(clock, command, attention, data) pins, check for error
if(error == 0){
Serial.println("Found Controller, configured successful");
Serial.println("Try out all the buttons, X will vibrate the controller, faster as you press harder;");
Serial.println("holding L1 or R1 will print out the analog stick values.");
Serial.println("Go to www.billporter.info for updates and to report bugs.");
}
else if(error == 1)
Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips");
else if(error == 2)
Serial.println("Controller found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips");
//Serial.print(ps2x.Analog(1), HEX);
type = ps2x.readType();
switch(type) {
case 0:
Serial.println("Unknown Controller type");
break;
case 1:
Serial.println("DualShock Controller Found");
break;
case 2:
Serial.println("GuitarHero Controller Found");
break;
}
ps2x.enableRumble(); //enable rumble vibration motors
if(!ps2x.enablePressures()) //enable reading the pressure values from the buttons.
Serial.println("Controller refusing Pressures mode, may not support it.");
}
void loop(){
/* You must Read Gamepad to get new values
Read GamePad and set vibration values
ps2x.read_gamepad(small motor on/off, larger motor strenght from 0-255)
if you don't enable the rumble, use ps2x.read_gamepad(); with no values
you should call this at least once a second
*/
if(error != 0) //skip loop if no controller found
return;
if(type == 2){ //Guitar Hero Controller
ps2x.read_gamepad(); //read controller
if(ps2x.Button(UP_STRUM) || ps2x.Button(DOWN_STRUM)) //will be TRUE as long as either is pressed
{
if(ps2x.ButtonPressed(GREEN_FRET))
digitalWrite(FlameEffect1, HIGH);
if(ps2x.ButtonPressed(RED_FRET))
digitalWrite(FlameEffect2, HIGH);
if(ps2x.ButtonPressed(YELLOW_FRET))
digitalWrite(FlameEffect3, HIGH);
if(ps2x.ButtonPressed(BLUE_FRET))
digitalWrite(FlameEffect4, HIGH);
if(ps2x.ButtonPressed(ORANGE_FRET))
digitalWrite(FlameEffect5, HIGH);
}
else{ //otherwise the up or down strum isn't being hit and no notes should be firing.
digitalWrite(FlameEffect1, LOW);
digitalWrite(FlameEffect2, LOW);
digitalWrite(FlameEffect3, LOW);
digitalWrite(FlameEffect4, LOW);
digitalWrite(FlameEffect5, LOW);
}
}
delay(20);
}