nikhil_agrwl
Published © GPL3+

Smartphone Controlled Arduino Bot

Control this Arduino bot from your smartphone via Bluetooth.

IntermediateFull instructions provided3 hours501
Smartphone Controlled Arduino Bot

Things used in this project

Story

Read more

Schematics

Circuit Diadram

Circuit Diagram for the bot

Code

Source Code

Arduino
Source code for the working bot
int lm1=3,lm2=5;
int rm1=9,rm2=6;
int command=0;
int PWMSpeed=200;




void setup() {
  Serial.begin(9600);
  pinMode(lm1,OUTPUT);
  pinMode(lm2,OUTPUT);
  pinMode(rm1,OUTPUT);
  pinMode(rm2,OUTPUT);

  motor_off();

}

void loop() {
    if(Serial.available() > 0)
    {
      command = Serial.read();
      Serial.println(command);
    if(command == '2')
    {
      forward();
    } 
    else if(command == '1')
    {
      backward();
    } 
    else if(command == '3')
    {
      right(); 
    } 
    else if(command == '4')
    {
      left();
    } 
    else if(command == '0')
    {
      motor_off();        
    } 
    else 
    {
      motor_off();
    }
   }
}



void motor_off() 
{
  Serial.print("Motor :  STOP\n");
  digitalWrite(lm1, LOW);
  digitalWrite(lm2, LOW);

  digitalWrite(rm1, LOW);
  digitalWrite(rm2, LOW);
}

void right() 
{
  Serial.print("Motor :  LEFT\n");
  analogWrite(lm1, PWMSpeed);
  digitalWrite(lm2, LOW);

  analogWrite(rm1, PWMSpeed);
  digitalWrite(rm2, LOW);

}

void left() 
{
  Serial.print("Motor :  RIGHT\n");
  digitalWrite(lm1, LOW);
  analogWrite(lm2, PWMSpeed);

  digitalWrite(rm1, LOW);
  analogWrite(rm2, PWMSpeed);

}

void forward() 
{
  Serial.print("Motor :  FORWARD\n");
  digitalWrite(lm1, LOW);
  digitalWrite(lm2, HIGH);

  digitalWrite(rm1, HIGH);
  digitalWrite(rm2, LOW);
}

void backward() 
{
  Serial.print("Motor :  BACK\n");
  digitalWrite(lm1, HIGH);
  digitalWrite(lm2, LOW);

  digitalWrite(rm1, LOW);
  digitalWrite(rm2, HIGH);
}

Credits

nikhil_agrwl

nikhil_agrwl

1 project • 1 follower

Comments