Hi, I am using a robot with the shield pololu VNH5019, an Arduino UNO and a plasystation Joysick, but the Joystick no connect to reciver, I checked the connections but the Joystick no connect, I use the Analog pins for the reciver because the shield use the digital pins. Here attached the program. Thanks.
P.D: Sorry for my English I am learning.
//===============================================================================================================================//
// Definicion de Ps2 Joystick y parametros.
#include <PS2X_lib.h>
PS2X ps2x;
int error = 0;
byte type = 0;
byte vibrate = 0;
int yl,xl,yr,yx,_yr,_yl;
int automata = 1;
//===============================================================================================================================//
// Definicion de la shield VNH5019 y parametros.
#include <DualVNH5019MotorShield.h>
DualVNH5019MotorShield md;
//===============================================================================================================================//
// Definición de pines.
const int M1_INA = 2;
const int M1_INB = 4;
const int M1_PWM = 9;
const int M2_INA = 7;
const int M2_INB = 8;
const int M2_PWM = 10;
//===============================================================================================================================//
// Configuración de pines.
void setup() {
error = ps2x.config_gamepad(A0,A2,A3,A1, true, true);
pinMode(M1_INA,OUTPUT);
pinMode(M1_INB,OUTPUT);
pinMode(M1_PWM,OUTPUT);
pinMode(M2_INA,OUTPUT);
pinMode(M2_INB,OUTPUT);
pinMode(M2_PWM,OUTPUT);
}
//===============================================================================================================================//
// Invocación de funciones.
void loop() {
Leer();
Actuar();
}
//===============================================================================================================================//
// Lectura de los Joysticks.
void Leer(){
ps2x.read_gamepad();
yl = ps2x.Analog(PSS_LY), DEC;
yr = ps2x.Analog(PSS_RY), DEC;
_yl = map(yl,0,255,-400,400);
_yr = map(yr,0,255,-400,400);
delay(50);
}
//===============================================================================================================================//
// Movimiento de motores.
void Actuar(){
md.setM1Speed(_yl);
md.setM2Speed(_yr);
}
//===============================================================================================================================//