EasyManua.ls Logo

Keywish Hummer-Bot - 3.2.7 Mobile Phone Bluetooth Control

Keywish Hummer-Bot
108 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
94
handle is pressed. Through the "fourth step in the experimental step" we can get the
code of all the buttons * /
{
int val=200;
analogWrite (E1,0);
analogWrite(M1, val); //the speed value of motorA is val
analogWrite (M2,0);
analogWrite(E2, val); //the speed value of motorA is val
delay(200); analogWrite (M1,0);
analogWrite(E1, 0);
analogWrite (M2,0);
analogWrite(E2, 0);
}
if(ps2x.Button(PSB_L2)||(ps2x.Button(PSB_PAD_LEFT)))
/ * If the received signal is PSB_L2 or PSB_PAD_LEFT, execute the command in {}, ie
turn left. The reason why two codes are used here is because we have set two keys on
the PS2 handle for turning left, Just press one of them to complete the turn left * /
{
int val=200;
analogWrite (M1,0);
analogWrite(E1, val); //the speed value of motorA is val
analogWrite (E2,0);
analogWrite(M2, val); //the speed value of motorA is val
delay(200); analogWrite (M1,0);
analogWrite(E1, 0);
analogWrite (M2,0);
analogWrite(E2, 0);
}
if(ps2x.Button(PSB_PAD_DOWN)) / * If the received signal is PSB_PAD_DOWN, execute the
command in {} to stop. * /
{
int val=180;
analogWrite (E1,0);
analogWrite(M1, val); //the speed value of motorA is val
analogWrite (E2,0);
analogWrite(M2, val); //the speed value of motorA is val
}

Table of Contents