Keywish Hummer-Bot Instruction Manual page 98

Table of Contents

Advertisement

if(ps2x.Button(PSB_L1))
{}. * /
{
vb
= ps2x.Analog(PSS_LY);
and assign this value to the variable vb. The joystick range is 0-255. When you press
L1, you can toggle the joystick to generate the corresponding value. If L1 is not
pressed, dial rocker will not produce the corresponding value. Because PWM is also 0-
255, so we directly convert the value generated by the joystick into PWM, so as to
control the motor speed. Experimental results are: Press the L1, dial the left rocker,
the car can be accelerated or slowed down in the process of progress. * /
analogWrite
(M1,0);
analogWrite(E1, vb);
analogWrite
(M2,0);
analogWrite(E2, vb);
}
if(ps2x.Button(PSB_R1))
{}. * /
{
KK
= ps2x.Analog(PSS_RY);
assign this value to the variable kk. The joystick range is 0-255. When you press R1,
you can toggle the joystick to generate the corresponding value. If R1 is not pressed,
dial rocker will not produce the corresponding value. Because PWM is also 0-255, so we
directly convert the value generated by the joystick into PWM, so as to control the
motor speed. The experimental result is: press R1, dial the right joystick, the car can
be accelerated or decelerated in the process of receding. * /
analogWrite(M1,KK);
analogWrite(E1, 0);
analogWrite(M2,KK);
analogWrite(E2,0);
}
delay(50);
}
In the above program, we used a lot of buttons, but they are all showed in code form and no details to
any keys. Now we will know about these buttons, if you download the above program directly to the
development board, you can control the car with PS2 handle in accordance with the instructions below as
shown in Fig.3.2.46. Of course, we encourage users to write programs, set keys according to their own ideas,
so the development of the car will be very meaningful.
/ * If the received signal is PSB_L1, execute the command in
/ * Read the value of PSS_LY, that is, the joystick value,
//the speed value of motorA is vb
//the speed value of motorB is vb
/ * If the received signal is PSB_R1, execute the command in
/ * Read the value of PSS_RY, ie the joystick value, and
//the speed value of motorA is kk
//the speed value of motorA is kk
95

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Hummer-Bot and is the answer not in the manual?

Related Products for Keywish Hummer-Bot

Table of Contents

Save PDF