int
vb;
int
KK;
void
setup()
{
Serial.begin(9600);
error
= ps2x.config_gamepad(11,7,8,4, true, true);
/ * Set the receiving port on the Arduino * /
}
void
loop()
{
ps2x.read_gamepad(false, vibrate);
if(ps2x.Button(PSB_L3))
{}, ie stop, "PSB_L3" is the code returned when the button on the PS2 handle is
pressed, and through the "fourth step in the experimental step" we can get All key
coding * /
{
int
val=0
;
analogWrite
(M1,0);
analogWrite(E1, val);
analogWrite
(M2,0);
analogWrite(E2, val);
}
if(ps2x.Button(PSB_PAD_UP))
command in {}, ie forward, "PSB_PAD_UP" is the code returned when the button on the PS2
handle is pressed, and through the "fourth step in the experimental step" we can obtain
All key coding * /
{
int
val=180
;
analogWrite
(M1,0);
analogWrite(E1, val);
analogWrite
(M2,0);
analogWrite(E2, val);
}
if(ps2x.Button(PSB_R2)||(ps2x.Button(PSB_PAD_RIGHT)))
/ * If the received signal is PSB_R2 or PSB_PAD_RIGHT, execute the command in {}, ie,
turn right. The reason why two codes are used here is because we have set two buttons
on the PS2 handle for turning right, Just press one of them to complete the right turn
"PSB_R2 and PSB_PAD_RIGHT" is the code that is returned when the button on the PS2
/ * Read the signal received by the receiver * /
/ * If the received signal is PSB_L3, execute the command in
//the speed value of motorA is val
//the speed value of motorA is val
/ * If the received signal is PSB_PAD_UP, execute the
//the speed value of motorA is val
//the speed value of motorA is val
93
Need help?
Do you have a question about the Hummer-Bot and is the answer not in the manual?