PS2X_Examp_My5.zip (6232Bytes)
Hello colleagues. I'm doing the robot controlled by PS2 gamepad. as the driver of the motor I use
TREX controller
in charge of the flooded sketch Wild_Thumper.
through the I2S interface Tirex upravlyaetsya Arduino Nano. to which, in turn, connected to a Bluetooth module gamepad.
problem arose with control buttons. through the analog sticks car rides, but I want to do the same control buttons. so I tried to do a push-button control of the servo drives, also to no avail. help me please.
I spread your sketch filled in Arduino Nano,
Here's a code not working, even though the idea is to pee?
if(ps2x.Button(PSB_PAD_UP)) { //will be TRUE as long as button is pressed
sv[0] = 2300;
lmspeed = 255;
rmspeed = 255;
lmbrake =0; //выкл. стоп
rmbrake =0;
But from analog joystick it works
lmspeed = -(ps2x.Analog(PSS_LY)-128); //скопировать данные джойстика в регистры правого и левого двигателя
int tmp = -(ps2x.Analog(PSS_LX)-128); //
rmspeed = lmspeed;
lmspeed -= tmp; lmspeed *=2;
rmspeed += tmp; rmspeed *=2;
if (lmspeed>255) lmspeed =255; //ограничить макс. значения моторов
if (rmspeed>255) rmspeed =255; //
if (lmspeed<-255) lmspeed =-255; //
if (rmspeed<-255) rmspeed =-255; //
lmbrake =0; //выкл. стоп
rmbrake =0; //
sv[0] = (map(ps2x.Analog(PSS_RY), 0, 255, 700, 2300)); ;
sv[1] = (map(ps2x.Analog(PSS_RX), 0, 255, 950, 1750)); ;
//sv[1] = 1400 -(ps2x.Analog(PSS_RX)-128)*2,2;