About Arduino Bluetooth Mini Tank
The App sends Bluetooth commands to the Mini Tank: U= Forward, D= Back, L= Left, R= Right, S= Stop
I didn't find any app for my Mini tank on Google Play, so i made one. Enjoy.
CODE:
/*
L = left
R = right
F = forward
B = backward
*/
int pinLB = 12; // define pin 12
int pinLF = 3; // define pin 3
int pinRB = 13; // define pin 13
int pinRF = 11; // define pin 11
int val;
void setup()
{
Serial.begin(9600); // define pin for motor output
pinMode(pinLB,OUTPUT); // pin 12
pinMode(pinLF,OUTPUT); // pin 3 (PWM)
pinMode(pinRB,OUTPUT); // pin 13
pinMode(pinRF,OUTPUT); // pin 11 (PWM)
}
void advance() // move forward
{
digitalWrite(pinLB,LOW); // right wheel moves forward
digitalWrite(pinRB, LOW); // left wheel moves forward
analogWrite(pinLF,255);
analogWrite(pinRF,255);
}
void stopp() // stop
{
digitalWrite(pinLB,HIGH);
digitalWrite(pinRB,HIGH);
analogWrite(pinLF,0);
analogWrite(pinRF,0);
}
void right() // turn right (single wheel)
{
digitalWrite(pinLB,LOW); // left wheel moves forward
digitalWrite(pinRB,HIGH); // right wheel moves backward
analogWrite(pinLF, 255);
analogWrite(pinRF,255);
}
void left() // turn left (single wheel)
{
digitalWrite(pinLB,HIGH); // left wheel moves forward
digitalWrite(pinRB,LOW); // right wheel moves backward
analogWrite(pinLF, 255);
analogWrite(pinRF,255);
}
void back() // move backward
{
digitalWrite(pinLB,HIGH); // motor moves to left rear
digitalWrite(pinRB,HIGH); // motor moves to right rear
analogWrite(pinLF,255);
analogWrite(pinRF,255);
}
void loop()
{
val=Serial.read();
if(val=='U')advance();
if(val=='D')back();
if(val=='L')left() ;
if(val=='R')right();
if(val=='S')stopp();
} The App Sends Bluetooth commands to the Mini Tank: U = Forward, D = Back, L = Left, R = Right, S = Stop
I did not find any app for my Mini tank on Google Play, so the homemade one. Enjoy.
CODE:
/ *
L = left
R = right
F = forward
B = backwardness
* /
int pinLB = 12; // Define pin 12
int pinLF = 3; // Define pin 3
int pinRB = 13; // Define pin 13
int pinRF = 11; // Define pin 11
int val;
void setup ()
{
Serial.begin (9600); // Define pin for motor output
pinMode (pinLB, OUTPUT); // Pin 12
pinMode (pinLF, OUTPUT); // Pin 3 (PWM)
pinMode (pinRB, OUTPUT); // Pin 13
pinMode (pinRF, OUTPUT); // Pin 11 (PWM)
}
void advance () // move forward
{
Digital write (pinLB, LOW); // Right wheel moves forward
Digital write (pinRB, LOW); // Left wheel moves forward
analog write (pinLF, 255);
analog write (pinRF, 255);
}
void stop () // stop
{
Digital write (pinLB, HIGH);
Digital write (pinRB, HIGH);
analog write (pinLF, 0);
analog write (pinRF, 0);
}
void right () // turn right (single wheel)
{
Digital write (pinLB, LOW); // Left wheel moves forward
Digital write (pinRB, HIGH); // Right wheel moves backward
analog write (pinLF, 255);
analog write (pinRF, 255);
}
void left () // turn left (single wheel)
{
Digital write (pinLB, HIGH); // Left wheel moves forward
Digital write (pinRB, LOW); // Right wheel moves backward
analog write (pinLF, 255);
analog write (pinRF, 255);
}
void back () // move backward
{
Digital write (pinLB, HIGH); // Motor moves to left rear
Digital write (pinRB, HIGH); // Motor moves to right rear
analog write (pinLF, 255);
analog write (pinRF, 255);
}
void loop ()
{
val = Serial.read ();
if (val == 'U') Advance ();
if (val == 'D') back ();
if (val == 'L') left ();
if (val == 'R') right ();
if (val == 'S') stop ();
}
by S####:
If you have the KS0071 Mini Tank kit from Keyestudio, this is definitely the app to get. I put together the kit a month or so ago, and there wasn't any decent app available. I left it alone for a few weeks and I saw that this app came out. Awesome! It worked right away, and does exactly what it needs to do, but nothing else. Perfect. Thanks!