arduino ide

Arduino Ide | Building a Wireless Bluetooth Controlled Robot Car with Arduino ide : A Complete Instruction

Table of Contents

Arduino ide should be read since if you are interested in robotics technology or if you just want to create an easily controlled robot, this article is for you. This is an in-depth tutorial that helps you build a robot vehicle capable of receiving commands over Bluetooth and interacting with a custom Android application.


Step 1: Making the Body of the Robot

The body is the robot’s structural strength upon which all the electrical components sit. To make a lightweight and rigid structure:

Sunboards have the same strength as cardboards and are less expensive.

Using a craft knife or laser cutter, cut out the following pieces:

2 rectangular pieces of 10.5 x 13.5 cm which will serve as the base and top plates.

2 strips of 7.5 x 2.3 cm which can act as side supports.

2 strips of 11.5 x 2.3 cm serving as front and rear supports.

1 strip of 4.3 x 2.3 cms which can be used for the battery compartment.

2 strips of 10.5 x 3.5 cm for the motor mounts.

You can now glue, screw, or hot glue the components together to complete the chassis.

It is worth cutting extra pieces for easy replacement while working through construction.

Step 2: Configuring the Motors

In pairs, from the left, right and across each pair of the motors connect all the four motors in parallel

Connect pins in cross wiring to allow for the connection.

This section may also be supported by the video or circuit schematic.

Step 3: Motors Connections to the Motor Driver

With L298N Module:

Insert motors onto the screw terminal of the driver.

The polarity of controls and direction sequence is determined by the inputs to the Arduino.

Step 4: Connection of the Motor Driver to the Arduino ide

Design how the motor driver is to be attached on the Arduino Uno board:

Proper connection of female bergstrips, male bergstrips and relimate connectors.

Use an Arduino Protoshield.Try the removed connection sockets.

Step 5: Introducing of RGB Neopixel LEDs

Decorate your robot making it look more cool and attractive using RGB Neopixel LEDs

Fix the LEDs on the Arduino Board.

Modify the colors of the LEDs in the Android app developed for this purpose.

 

Step 6: Designing the Custom Android App for the User

With the help of MIT App Inventor:

The Bluetooth capability must be integrated while constructing the interfaces so commands can be sent.

Moving the robot, directing LEDs and coloring it, and creating patterns with them.

 

Step 7: Circuit Diagram as well as Assembly

See below the complete circuit diagram:

Check that every connection is predetermined in construction is persistent and secure.

Make sure to confirm the connectivity between the motor driver, Arduino, and Bluetooth once again.

 

Step 8: Tuning and Adjustment

Perform some movement tests for the robot and check the LED in the robot as well.

Realign the motors and the Android application accordingly.

Components Required:

  • An Arduino Uno.

  • An L298N Motor Driver.

  • 4 DC motors.

  • Solar boards.

  • RGB Neon pixcels LED

  • We need a bluetooth module for arduino.

  • An android phone.

  • The software MIT App Inventor.

  • Jumping wires.

  • Bergstrips.

  • Relimate connectors.

  • Tips and Variations:

Precision can be improved by switching to a more complex motor driver.

Integrate any sensors for line following or for obstacle avoidance.

Try other types of Arduino boards or microcontrollers.

Using the above procedures, you have built a fully operational Bluetooth controlled wireless robot car which is AKB01 all by yourself and have improved your robotics skills and knowledge.

Bluetooth Controlled Robot Arduino Code

The code for Bluetooth controlled robot which basis is Arduino is somehow complicated. This reason made us break the total code then into three sections.

The working of this circuit is very simple and easy to understand. First, we have the Arduino which is working as the brains of the circuit. Next, we have the Bluetooth module. The Bluetooth module is connected to pin 13 and 10 of the Arduino that we are using as the software serial. Next, we are using pins 11,12,8, and 7 to connect our WS2812B RGB leds. Finally, we are using pins 9, 6, 5 and 4 to connect the L298N motor driver IC that is driving four of our motors. Finally, to power it all up, we are using a 9V battery.

Arduino

L298N

3

IN1

9

IN2

5

IN3

6

IN4

VIN

+5V

GND

GND

Arduino

HC05

10

Tx

11

Rx

+5V

VCC

GND

GND

Arduino

NeoPixel

8

Left LED

7

Right LED

12

Front LED Data

13

Back LED Data


The working of this circuit is very easy.

Arduino Code for Bluetooth Controlled Robot

The code for the Arduino, and Bluetooth-based robot is a little bit complicated, so we separate the total code into three separate files this way we can change things quickly in the code if needed.

				
					Arduino_Bluetooth_Bot_main


#include <SoftwareSerial.h>


SoftwareSerial mySerial(10, 11); // RX, TX


void setup() {


  // Open serial communications and wait for port to open:


  Serial.begin(9600);


  mySerial.begin(38400);


  while (!Serial) {


    ; // wait for serial port to connect. Needed for native USB port only


  }


  Serial.println("Sending AT...");


  mySerial.write("AT");


  if (mySerial.available() > 0) {


    Serial.write(mySerial.read());


  }


  // set the data rate for the SoftwareSerial port


  Serial.println("loop begins");


  LED_setup();


}


char rcd = ' ';


int spd = 100;


unsigned long time_now = 0;


void loop() { // run over and over


  if (mySerial.available()) {


    rcd = mySerial.read();


    Serial.write(rcd);


  }


  unsigned long time_now = 0;


  if (rcd == 'O')


  {


    R_LED(1);


    L_LED(1);


    F_LED(1);


    B_LED(1);


  }


  if (rcd == 'o')


  {


    R_LED(0);


    L_LED(0);


    F_LED(0);


    B_LED(0);


  }


  if (rcd == 'X')


  { L_LED(1);


  }


  if (rcd == 'x')


  {


    L_LED(0);


  }


  if (rcd == 'P')


  {


    R_LED(1);


  }


  if (rcd == 'p')


  { R_LED(0);


  }


  if (rcd == 'W')


  { F_LED(1);


  }


  if (rcd == 'w')


  { F_LED(0);


  }


  if (rcd == 'U')


  { B_LED(1);


  }


  if (rcd == 'u')


  { B_LED(0);


  }


  if (rcd == '0')


  { spd = 80;


  }


  if (rcd == '1')


  { spd = 100;


  }


  if (rcd == '3')


  { spd = 120;


  }


  if (rcd == '5')


  { spd = 180;


  }


  if (rcd == 'q')


  { spd = 255;


  }


  if (rcd == 'F')


  { Forward();


    time_now = millis();


    while (millis() < time_now + 100) {}


  }


  else if (rcd == 'B')


  { time_now = millis();


    while (millis() < time_now + 100) {}


    Backward();


  }


  else if (rcd == 'I')


  { time_now = millis();


    while (millis() < time_now + 100) {}


    FdRight();


  }


  else if (rcd == 'J')


  { time_now = millis();


    while (millis() < time_now + 100) {}


    BkRight();


  }


  else if (rcd == 'R')


  { time_now = millis();


    while (millis() < time_now + 100) {}


    SharpRight();


  }


  else if (rcd == 'L')


  { time_now = millis();


    while (millis() < time_now + 100) {}


    SharpLeft();


  }


  else if (rcd == 'G')


  { time_now = millis();


    while (millis() < time_now + 100) {}


    FdLeft();


  }


  else if (rcd == 'H')


  { time_now = millis();


    while (millis() < time_now + 100) {}


    BkLeft();


  }


  else


    Stop();


}


 


LED_Control


#include <Adafruit_NeoPixel.h>


#ifdef __AVR__


#include <avr/power.h>


#endif


#define F_LED_PIN        12 //Front LED


#define F_LED_PIXEL       6


#define B_LED_PIN        13  //Back LED


#define B_LED_PIXEL       6


#define R_LED_PIN        7 //Right LED


#define R_LED_PIXEL       1


#define L_LED_PIN        8 //Left LED


#define L_LED_PIXEL       1


Adafruit_NeoPixel F_LED_STRIP(F_LED_PIXEL, F_LED_PIN, NEO_GRB + NEO_KHZ800);


Adafruit_NeoPixel B_LED_STRIP(B_LED_PIXEL, B_LED_PIN, NEO_GRB + NEO_KHZ800);


Adafruit_NeoPixel R_LED_STRIP(R_LED_PIXEL, R_LED_PIN, NEO_GRB + NEO_KHZ800);


Adafruit_NeoPixel L_LED_STRIP(L_LED_PIXEL, L_LED_PIN, NEO_GRB + NEO_KHZ800);


void LED_setup()


{


  #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)


  clock_prescale_set(clock_div_1);


#endif


  F_LED_STRIP.begin();


  B_LED_STRIP.begin();


  R_LED_STRIP.begin();


  L_LED_STRIP.begin();


  R_LED_STRIP.clear();


  L_LED_STRIP.clear();


  F_LED_STRIP.clear();


  B_LED_STRIP.clear();


}


void R_LED(int a)


{


  if(a==1)


  {


    R_LED_STRIP.clear();


    R_LED_STRIP.setPixelColor(0, R_LED_STRIP.Color(0, 255, 255));


   R_LED_STRIP.show();   // Send the updated pixel colors to the hardware.


  }


  else {


    R_LED_STRIP.clear();


     R_LED_STRIP.show();


  }   


}


void L_LED(int a)


{


  if(a==1)


  {


    L_LED_STRIP.clear();


    L_LED_STRIP.setPixelColor(0, L_LED_STRIP.Color(0, 255, 255));


   L_LED_STRIP.show();   // Send the updated pixel colors to the hardware.


  }


  else


  {


     L_LED_STRIP.clear();


     L_LED_STRIP.show();


  }


}


void F_LED(int a)


{


  if(a==1)


  {


    F_LED_STRIP.clear();


    F_LED_STRIP.setPixelColor(0, F_LED_STRIP.Color(255, 255, 255));


    F_LED_STRIP.setPixelColor(1, F_LED_STRIP.Color(0, 0, 50));


    F_LED_STRIP.setPixelColor(2, F_LED_STRIP.Color(0, 0, 50));


    F_LED_STRIP.setPixelColor(3, F_LED_STRIP.Color(0, 0, 50));


    F_LED_STRIP.setPixelColor(4, F_LED_STRIP.Color(0, 0, 50));


    F_LED_STRIP.setPixelColor(5, F_LED_STRIP.Color(255, 255, 255));


   F_LED_STRIP.show();   // Send the updated pixel colors to the hardware.


  }


  else if(a==0)


  {


    F_LED_STRIP.clear();


    F_LED_STRIP.show();


  }


}


void B_LED(int a)


{


  if(a==1)


  {


    B_LED_STRIP.clear();


    B_LED_STRIP.setPixelColor(0, B_LED_STRIP.Color(255, 0, 0));


    B_LED_STRIP.setPixelColor(1, B_LED_STRIP.Color(0, 50, 0));


    B_LED_STRIP.setPixelColor(2, B_LED_STRIP.Color(0, 50, 0));


    B_LED_STRIP.setPixelColor(3, B_LED_STRIP.Color(0, 50, 0));


    B_LED_STRIP.setPixelColor(4, B_LED_STRIP.Color(0, 50, 0));


    B_LED_STRIP.setPixelColor(5, B_LED_STRIP.Color(255, 0, 0));


    B_LED_STRIP.show();   // Send the updated pixel colors to the hardware.


  }


  else if(a==0)


  {


    B_LED_STRIP.clear();


    B_LED_STRIP.show();


  }


}


 


Movements


void Forward()


{


  analogWrite(5, spd);


  digitalWrite(6, 0);


  analogWrite(9, spd);


  digitalWrite(3, 0);


  //  delay(50);


}


void Backward()


{


  digitalWrite(5, 0);


  analogWrite(6, spd);


  digitalWrite(9, 0);


  analogWrite(3, spd);


}


void Stop()


{


  analogWrite(5, 0);


  digitalWrite(6, 0);


  analogWrite(9, 0);


  digitalWrite(3, 0);


}


void FdRight()


{


  analogWrite(5, spd);


  digitalWrite(6, 0);


  digitalWrite(9, 0);


  analogWrite(3, 0);


}


void BkRight()


{


  analogWrite(5, 0);


  digitalWrite(6, 0);


  digitalWrite(9, 0);


  analogWrite(3, spd);


}


void SharpRight()


{


  analogWrite(5, spd);


  digitalWrite(6, 0);


  digitalWrite(9, 0);


  analogWrite(3, spd);


}


void SharpLeft()


{


  digitalWrite(5, 0);


  analogWrite(6, spd);


  analogWrite(9, spd);


  digitalWrite(3, 0);


}


void BkLeft()


{


  digitalWrite(5, 0);


  analogWrite(6, spd);


  analogWrite(9, 0);


  digitalWrite(3, 0);


}


void FdLeft()


{


  digitalWrite(5, 0);


  analogWrite(6, 0);


  analogWrite(9, spd);


  digitalWrite(3, 0);


}


				
			
Voice Connection based Security system with ESP8266 and Arduino for IoT in Home Automation

Leave a Reply

WhatsApp
My Cart
Wishlist
Recently Viewed
Categories