I'm new to the C++ language that is used for sketches. I've got some books and looked at programs but there is a statement in a program that I'm looking at which I can't understand. The statement is
PS2X ps2x; // create PS2 Controller Class
I understand // create PS2 Controller Class is a comment but the comment doesn't help me understand the rest of the line.
The question is what is the statement mean and what does it do?
The statement in context is as follows
#include <PS2X_lib.h> //for v1.6
/******************************************************************
- set pins connected to PS2 controller:
-
- 1e column: original
-
- 2e colmun: Stef?
- replace pin numbers by the ones you use
******************************************************************/
#define PS2_DAT 8 //14
#define PS2_CMD 11 //15
#define PS2_SEL 10 //16
#define PS2_CLK 12 //17
/******************************************************************
- select modes of PS2 controller:
-
- pressures = analog reading of push-butttons
-
- rumble = motor rumbling
- uncomment 1 of the lines for each mode selection
******************************************************************/
#define pressures true
//#define pressures false
#define rumble true
//#define rumble false
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 connect the controller,
//or call config_gamepad(pins) again after connecting the controller.
int error = 0;
byte type = 0;
byte vibrate = 0;
void setup(){
pinMode(3, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(9, OUTPUT);
Serial.begin(57600);
delay(300); //added delay to give wireless ps2 module some time to startup, before configuring it
//CHANGES for v1.6 HERE!!! *PAY ATTENTION
//setup pins and settings: GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error
error = ps2x.config_gamepad(PS2_CLK, PS2_CMD, PS2_SEL, PS2_DAT, pressures, rumble);