STEMpedia
Published © CC BY

4-Wheel Robot Made With Arduino Controlled Using Dabble

This project will show you how to make a DIY 4-wheel robot that can be controlled using a smartphone via Dabble, a mobile application.

IntermediateFull instructions provided38,411
4-Wheel Robot Made With Arduino Controlled Using Dabble

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
DC motor (generic)
×4
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Dual H-Bridge motor drivers L293D
Texas Instruments Dual H-Bridge motor drivers L293D
×1
DC Terminal Block
×1
Motor Mounts
×1
Wheels
×1

Software apps and online services

Arduino IDE
Arduino IDE
STEMpedia Dabble

Story

Read more

Schematics

Fritzing Diagram of Four Wheel Robot

Code

robot.ino

Arduino
/* 
 *  
 *  this project demonstrate controlling arduino 4 wheel robot using Dabble app
 *  we will be using gamepad module in digital mode 
 *  for more information about gamepad go to https://thestempedia.com/docs/dabble/game-pad-module/
 *  
 *  in this project we will be using HC-05 bluetooth module  
 *  for arduino "UNO" use bluetooth module buadrate below 38400
 *  
 *  connection of bluetooth module with arduino 
 *  
 *  HC-05 bluetooth module ----> arduino "UNO"
 *  
 *              Tx         ----> 2
 *              Rx         ----> 3 
 *              
 *  Written by by Punit chotaliya, STEMpedia         
 *  on 16 jan 2019
 *              
 */

//To include the GamePad module in the Arduino program, you have to 
//include the following header:
#define CUSTOM_SETTINGS
#define INCLUDE_GAMEPAD_MODULE

//include Dabble app library 
#include <Dabble.h>

#define motor1_en 10      // motor 1 enable pin 
#define motor2_en 11      // motor 2 enable pin 
#define motor1_dir1 4     // motor 1 input1 (InputA) 
#define motor1_dir2 5     // motor 1 input2 (InputA)
#define motor2_dir1 6     // motor 2 input1 (InputB)
#define motor2_dir2 7    // motor 2 input2  (InputB)

void setup() 
   {
      // put your setup code here, to run once:
       
      Serial.begin(9600);   //  start serial communication using 9600 baudrate
      Dabble.begin(38400); // Enter your bluetooth module baudrate
                            // NOTE : for arduino "UNO" use bluetooth module buadrate below 38400 
      for(unsigned int i=4;i<8;i++)
         {
             pinMode(i,OUTPUT); // declaring input pins of motor1 and motor2 as a output pin 
         }
      pinMode(motor1_en,OUTPUT);  // declaring enable pins of motor as a output 
      pinMode(motor2_en,OUTPUT);

       
        
    }

void loop() 
     {
        // put your main code here, to run repeatedly:
        
         Dabble.processInput(); //To refresh the data that the arduino UNO got from the mobile app, you have to use the following line of code
      
        
        if (GamePad.isUpPressed()) // if UP is pressed in the gamepad then move robot forward
          {
             Serial.print("UP");
             forward();
          }

        else if (GamePad.isDownPressed()) // if DOWN is pressed in the gamepad then move robot backward
          {
             Serial.print("DOWN");
             backward();
          }

        else  if (GamePad.isLeftPressed()) // if LEFT is pressed in the gamepad then move robot LEFT
           {
              Serial.print("Left");
              left();
           }

        else  if (GamePad.isRightPressed()) // if RIGHT is pressed in the gamepad then move robot RIGHT
           {
               Serial.print("Right");
               right();
           }

        else // stop the robot
           {
            Serial.println("strop");
            Stop();
           }


     }

     void forward()  // function for robot forward movement 
     {
        analogWrite(motor1_en,255);
        analogWrite(motor2_en,255);
        digitalWrite(motor1_dir1,HIGH);
        digitalWrite(motor1_dir2,LOW);
        digitalWrite(motor2_dir1,HIGH);
        digitalWrite(motor2_dir2,LOW);
      
     }
     void backward() // function for robot backward movement 
     {
        analogWrite(motor1_en,255);
        analogWrite(motor2_en,255);
        digitalWrite(motor1_dir1,LOW);
        digitalWrite(motor1_dir2,HIGH);
        digitalWrite(motor2_dir1,LOW);
        digitalWrite(motor2_dir2,HIGH);
      
     }
     void left() // function for robot left movement 
     {
        analogWrite(motor1_en,255);
        analogWrite(motor2_en,255);
        digitalWrite(motor1_dir1,LOW);
        digitalWrite(motor1_dir2,HIGH);
        digitalWrite(motor2_dir1,HIGH);
        digitalWrite(motor2_dir2,LOW);
      
     }
     void right() // function for robot right movement 
     {
        analogWrite(motor1_en,255);
        analogWrite(motor2_en,255);
        digitalWrite(motor1_dir1,HIGH);
        digitalWrite(motor1_dir2,LOW);
        digitalWrite(motor2_dir1,LOW);
        digitalWrite(motor2_dir2,HIGH);
      
     }
     void Stop() // // function for no movement
     {
        analogWrite(motor1_en,0);
        analogWrite(motor2_en,0);
        digitalWrite(motor1_dir1,LOW);
        digitalWrite(motor1_dir2,LOW);
        digitalWrite(motor2_dir1,LOW);
        digitalWrite(motor2_dir2,LOW);
      
     }

evive Library

C/C++
No preview (download only).

Credits

STEMpedia

STEMpedia

42 projects • 169 followers
STEMpedia blends theory with experiential learning by offering state-of-the-art technology, projects, tutorials, courses, and much more.

Comments