In this project I will show you how to make a mobile app controlled two wheel arduino robot using Bluetooth connectivity. This is actually my beginning project what I did with my arduino Uno.
Things Used:
Arduino UNO is an open-source micro-controller board based on the ATmega328P micro-controller. The board is equipped with sets of digital and analog input/output (I/O).The board has 14 Digital pins, 6 Analog pins, and programmable with the Arduino-IDE via USB cable. It can be powered by an external 9V battery, though it accepts voltages between 7 and 20 volts. HC-05: HC-05 module is responsible for the Bluetooth communication between arduino and mobile phone. Here we use this module in slave mode as we are sending commands from mobile phone and the module is hearing to it. So we need not to connect the Tx pin as we are not transmitting anything from bot to mobile. This module works with 3.3V input voltage but a 3.3v voltage regulator is given on board so I am using 5V input voltage. For many of the modules the password would be “1234” or”0000”. Motor driver: In this project i used L298N driver module. But in simulation I used L293D IC. But I recommend you to use L298N module. Since the driver IC we used is a dual full bridge driver IC we can control two motors simultaneously using individual inputs. Input signal voltage should be 5v motor supply voltage is up to 45v, peak output current is 2A. App: I made an app for an android mobile using MIT App inventor. In MIT app we can do apps for our small hobby projects. For now you can download the application i use from my website. This app actually connects with the HC -05 Bluetooth module and works as a master which sends commands to slave according to your actions.( IN THE APP I GAVE A SLIDER TO CONTROL SPEED OF THE MOTORS BUT IN THE ARDUINO CODE I DIDN'T USE THAT ) Working: We are using 2 motors for the robot to move. Forward : To move forward we rotate both the motors in forward direction Backward : To move backward we rotate both the motors in reverse direction Left : To turn left we rotate the right motor in forward direction while leaving the left one in rest Right : To turn right we rotate the left motor in forward direction while leaving the right one in rest |
char inchar;
String input="";
boolean first=true;
int motorRpin1=3;
int motorRpin2=4;
int motorLpin1=5;
int motorLpin2=6;
void setup()
{
Serial.begin(9600);
Serial.flush();
pinMode(motorRpin1,OUTPUT);
pinMode(motorRpin2,OUTPUT);
pinMode(motorLpin1,OUTPUT);
pinMode(motorLpin2,OUTPUT);
}
void loop()
{
if(Serial.available())
{
delay(10);
while(Serial.available())
{
char inchar=Serial.read();//read input
input=inchar;
Serial.println(input);
}
}
if(input=="f")
{
digitalWrite(motorRpin1,1);
digitalWrite(motorRpin2,0);
digitalWrite(motorLpin1,1);
digitalWrite(motorLpin2,0);
}
if(input=="s")
{
digitalWrite(motorRpin1,0);
digitalWrite(motorRpin2,0);
digitalWrite(motorLpin1,0);
digitalWrite(motorLpin2,0);
}
if(input=="b")
{
digitalWrite(motorRpin1,0);
digitalWrite(motorRpin2,1);
digitalWrite(motorLpin1,0);
digitalWrite(motorLpin2,1);
}
if(input=="l")
{
digitalWrite(motorRpin1,1);
digitalWrite(motorRpin2,0);
digitalWrite(motorLpin1,0);
digitalWrite(motorLpin2,1);
}
if(input=="r")
{
digitalWrite(motorRpin1,0);
digitalWrite(motorRpin2,1);
digitalWrite(motorLpin1,1);
digitalWrite(motorLpin2,0);
}
}
String input="";
boolean first=true;
int motorRpin1=3;
int motorRpin2=4;
int motorLpin1=5;
int motorLpin2=6;
void setup()
{
Serial.begin(9600);
Serial.flush();
pinMode(motorRpin1,OUTPUT);
pinMode(motorRpin2,OUTPUT);
pinMode(motorLpin1,OUTPUT);
pinMode(motorLpin2,OUTPUT);
}
void loop()
{
if(Serial.available())
{
delay(10);
while(Serial.available())
{
char inchar=Serial.read();//read input
input=inchar;
Serial.println(input);
}
}
if(input=="f")
{
digitalWrite(motorRpin1,1);
digitalWrite(motorRpin2,0);
digitalWrite(motorLpin1,1);
digitalWrite(motorLpin2,0);
}
if(input=="s")
{
digitalWrite(motorRpin1,0);
digitalWrite(motorRpin2,0);
digitalWrite(motorLpin1,0);
digitalWrite(motorLpin2,0);
}
if(input=="b")
{
digitalWrite(motorRpin1,0);
digitalWrite(motorRpin2,1);
digitalWrite(motorLpin1,0);
digitalWrite(motorLpin2,1);
}
if(input=="l")
{
digitalWrite(motorRpin1,1);
digitalWrite(motorRpin2,0);
digitalWrite(motorLpin1,0);
digitalWrite(motorLpin2,1);
}
if(input=="r")
{
digitalWrite(motorRpin1,0);
digitalWrite(motorRpin2,1);
digitalWrite(motorLpin1,1);
digitalWrite(motorLpin2,0);
}
}
|
|