VEEROBOT Docs
StoreBlogWiki
  • 🌐Introduction
  • ROS Based Robots
    • 🐺Wolf Robot
      • ROS Introduction
      • Getting Started with ROS 2
      • Introduction to Wolf Robot
      • ROS 2 Setup
      • ROS Concepts
      • Using Wolf Examples
      • Creating a URDF File
      • Visualising in Gazebo
      • Controlling motors from ROS
      • LiDAR Basics & Control
      • Using a Camera with ROS2
      • ROS 2 Cleanup
      • ROS 2 Controller
      • Teleoperation
      • Slam Navigation
      • Wolf : Conclusion
  • Arduino Based Robots
    • 🚜Micro:Xbot
      • Preparations before First Use
      • Programming the Board
      • Powering the Board
      • Pin Mapping
      • Basic Programs
        • Blinking LED
        • Buzzer Program
        • Fading LED
        • RGB LED
        • Light Detection
        • Battery Voltage
        • Line Follower Module
        • Ultrasonic Sensor
        • Infrared Remote Control
        • Motor Control
        • Bluetooth Control
        • Display Test
        • Test Me
      • Robot Assembly
      • Advanced Programs
        • Bluetooth Controlled Robot
        • Obstacle Avoidance Robot
        • Line Follower Robot
  • ROS2 Repo
    • Introduction
    • Page 1
      • Sub Page 1
    • Page 2
Powered by GitBook
On this page
  1. Arduino Based Robots
  2. Micro:Xbot
  3. Basic Programs

Bluetooth Control

Wireless control for our micro:Xbot

PreviousMotor ControlNextDisplay Test

Last updated 2 years ago

Bluetooth is the standard for short-range, wireless communication between various electronic devices such as mobile phones, tablets, PC, headphones and even pressure cookers, which allow for adjusting the cooking timer and temperature through an app via Bluetooth.

To use this example, we will connect our robot to a mobile application and control the motors through the application. For this, we need to download VEELER application from Google Play Store (app is available for Android mobiles). Install the application and it is ready to use.

Bluetooth is a serial communication and we need to configure the pins on micro:Xbot to communicate with a mobile device. We can either use hardware serial pins (Tx, Rx) or any available pins can be configured as software serial pins.

Since we are using a FTDI programmer which uses Hardware Tx and Rx pins, we will use Pins D2 and D3 as software serial pins.

To connect mobile device to micro:Xbot, open Bluetooth services on your mobile phone and pair the module (HC-05) with password 0000 or 1234.

Upload the below program, Open Serial Monitor, Open VEELER Application, Click on HC-05 and start communicating with the board.

/*
  Bluetooth Control: Use a bluetooth module to wirelessly control the board

  At VEEROBOT, we invest time and resources providing this open source code,
  Please support VEEROBOT and open-source hardware by purchasing products
  from us @ http://veerobot.com
  -----------------------------------------------------------------------------
  You are free to redistribute it and/or modify it under the terms of the GNU
  Lesser General Public License as  published by the Free Software Foundation,
  either version 3 of the License, or (at your option) any later version.

  This Code is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Lesser General Public License for more details.

  See <http://www.gnu.org/licenses/>
*/

#include <SoftwareSerial.h>
#include "config.h"

SoftwareSerial btSerial(3, 2); // RX, TX
char cmd = 0;                //Variable for storing received data

void setup() {
  Serial.begin(9600);   // initialize serial connection
  btSerial.begin(9600); // initialize bluetooth connection
}

void loop() {
  decodeserialcommand();
}

void decodeserialcommand() {
  if (btSerial.available() > 0)   {
    cmd = btSerial.read();      //Read the incoming data and store it into variable data
    Serial.println(cmd);        //Print Value inside data in Serial monitor
    switch (cmd) {
      case 'W':
        Serial.println("Up Button");
        break;
      case 'X':
        Serial.println("Down Button");
        break;
      case 'A':
        Serial.println("Left Button");
        break;
      case 'D':
        Serial.println("Right Button");
        break;
      case 'Q':
        Serial.println("Top Left Button");
        break;
      case 'E':
        Serial.println("Top Right Button");
        break;
      case 'Z':
        Serial.println("Bottom Left Button");
        break;
      case 'C':
        Serial.println("Bottom Right Button");
        break;
      case 'S':
        Serial.println("Stop/Center Button");
        break;
      case 'T':
        Serial.println("Down Arrow");
        break;
      case 'Y':
        Serial.println("Up Arrow");
        break;
      case 'R':
        Serial.println("Red Button");
        break;
      case 'G':
        Serial.println("Blue Button");
        break;
      case 'B':
        Serial.println("Green Button");
        break;
      case 'O':
        Serial.println("White Button");
        break;
      case 'L':
        Serial.println("Gray Button");
        break;
      case 'M':
        Serial.println("Buzzer Button");
        break;
      case '1':
        Serial.println("Manual Key");
        break;
      case '2':
        Serial.println("Autonomous Key");
        break;
      case '3':
        Serial.println("Line Follower Key");
        break;
      default:
        break;
    }
  }
}

Click on the buttons on the app and the respective details are printed on the serial monitor.

🚜
VEEROBOT VEELER - Apps on Google PlayGooglePlay
VEELER Application on Playstore
Logo