Hello there,
I would like to use the PSX_analog library to drive a RC car through a PS2 controller.
I found the forum, loaded the library, but at the compilation, the program told me that the SPI is not declared.
I give you the sketch and the error message above:
#include "Psx_analog.h" // Includes the Psx Library
#define dataPin 14
#define cmndPin 15
#define attPin 16
#define clockPin 17
#define motorup 5
#define motordown 6
#define motorleft 9
#define motorright 10
#define center 0x7F
#define LEDPin 13
Psx Psx; // Initializes the library
void setup()
{
Psx.setupPins(dataPin, cmndPin, attPin, clockPin); // Defines what each pin is used
// (Data Pin #, Cmnd Pin #, Att Pin #, Clk Pin #)
Psx.initcontroller(psxAnalog);
pinMode(LEDPin, OUTPUT); // Establishes LEDPin as an output so the LED can be seen
//setup motoroutputs
pinMode(motorup, OUTPUT); // Establishes LEDPin as an output so the LED can be seen
pinMode(motordown, OUTPUT); // Establishes LEDPin as an output so the LED can be seen
pinMode(motorleft, OUTPUT); // Establishes LEDPin as an output so the LED can be seen
pinMode(motorright, OUTPUT); // Establishes LEDPin as an output so the LED can be seen
Serial.begin(9600);
Serial.println("Raw controller values");
// wait for the long string to be sent
delay(100);
}
void loop()
{
Psx.poll(); // Psx.read() initiates the PSX controller and returns
Serial.print("\n"); // the button data
Serial.print(Psx.Controller_mode, HEX); // prints value as string in hexadecimal (base 16)
Serial.print(Psx.digital_buttons, HEX); // prints value as string in hexadecimal (base 16)
Serial.print(Psx.Right_x, HEX); // prints value as string in hexadecimal (base 16)
Serial.print(Psx.Right_y, HEX); // prints value as string in hexadecimal (base 16)
Serial.print(Psx.Left_x, HEX); // prints value as string in hexadecimal (base 16)
Serial.print(Psx.Left_y, HEX); // prints value as string in hexadecimal (base 16)
if (Psx.digital_buttons & psxR2) // If the data anded with a button's hex value is true,
// it signifies the button is pressed. Hex values for each
// button can be found in Psx.h
{
digitalWrite(LEDPin, HIGH); // If button is pressed, turn on the LED
}
else
{
digitalWrite(LEDPin, LOW); // If the button isn't pressed, turn off the LED
}
delay(100);
}
So, during compilation, i found the next message:
/pentest/misc/arduino/libraries/ArduinoPSX/Psx_analog.cpp:59:17: error: Spi.h: No such file or directory
/pentest/misc/arduino/libraries/ArduinoPSX/Psx_analog.cpp: In member function ‘byte Psx::shift(byte)’:
/pentest/misc/arduino/libraries/ArduinoPSX/Psx_analog.cpp:66: error: ‘Spi’ was not declared in this scope
/pentest/misc/arduino/libraries/ArduinoPSX/Psx_analog.cpp: In member function ‘void Psx::setupPins(byte, byte, byte, byte)’:
/pentest/misc/arduino/libraries/ArduinoPSX/Psx_analog.cpp:113: error: ‘Spi’ was not declared in this scope
Somebody could help me to solve this problem ?
Thanks for your help and support.
Chris