jayesh_nawani
Published © GPL3+

Bluetooth-Controlled Arduino Robot

Make an Arduino-powered robot which is controlled by Bluetooth.

IntermediateShowcase (no instructions)4 hours17,121
Bluetooth-Controlled Arduino Robot

Things used in this project

Story

Read more

Schematics

Circuit assembly for Bluetooth Controlled Robotic Car

Make connections as per the circuit and upload the provided code to make the Robot Work

Code

Arduino Code for Bluetooth Controlled Robotic Car

C/C++
Upload the code in your arduino board, do proper connection as per video/post and your robot is ready to go.......
#include<SoftwareSerial.h>

SoftwareSerial bt(10,11); // assigning 10 as RX ans 11 as TX 

#define motor_left 5
#define motor_right 3

#define motor_right_dir 2
#define motor_left_dir 4

void setup() {
  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);

  while(!Serial){;} // waiting for serial communication to setup

  bt.begin(9600); // beginning the bluetooth connection
}

void loop() {
  
  bt.listen(); // listening to the bluetooth

  while(bt.available()) // till we are receiving the input continue in the loop
  {
      char ch = bt.read();  // reading one character at a time

      if(ch=='f'){          // action to be performed if input is 'f'
        digitalWrite(motor_left_dir,HIGH);
        digitalWrite(motor_right_dir,HIGH);
        analogWrite(motor_left,150);
        analogWrite(motor_right,150);
      }
      else if(ch == 'b'){       // action to be performed if input is 'b'
        digitalWrite(motor_left_dir,LOW);
        digitalWrite(motor_right_dir,LOW);
        analogWrite(motor_left,150);
        analogWrite(motor_right,150);
      }
      else if(ch == 'l'){       // action to be performed if input is 'l'
        digitalWrite(motor_left_dir,HIGH);
        digitalWrite(motor_right_dir,HIGH);
        analogWrite(motor_left,0);
        analogWrite(motor_right,120);
      }
      else if(ch == 'r'){     // action to be performed if input is 'r'
        digitalWrite(motor_left_dir,HIGH);
        digitalWrite(motor_right_dir,HIGH);
        analogWrite(motor_left,120);
        analogWrite(motor_right,0); 
      }
      else if(ch =='s'){  // action to be performed if input is 's'
        digitalWrite(motor_left_dir,HIGH);
        digitalWrite(motor_right_dir,HIGH);
        analogWrite(motor_left,0);
        analogWrite(motor_right,0); 
      }
  }

}

Credits

jayesh_nawani

jayesh_nawani

6 projects • 30 followers
Mechanical Engineer from India
Thanks to Viplove Saini.

Comments