Saher Iqbal
Published

Mobile Phone Controlled Robot

Concept explaining the working of a Mobile Phone Controlled Robot

BeginnerWork in progress4,096
Mobile Phone Controlled Robot

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
DC Motor, 12 V
DC Motor, 12 V
×1
Power Bank
×1

Software apps and online services

Arduino IDE
Arduino IDE
Dabble
STEMpedia Dabble

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver

Story

Read more

Schematics

Circuit

Code

Mobile_Controlled_Robot.ino

Arduino
#include <Dabble.h>
#include <SoftwareSerial.h>
#include <HttpResponse.h>
#include <HttpRequest.h>
#include <motorControls.h>
#include <JsonKeyChain.h>

#define CUSTOM_SETTINGS
#define INCLUDE_GAMEPAD_MODULE

int enRight = 7;    //Right motor
int MotorRightip1=1;
int MotorRightip2=3;
int enLeft = 6;     //Left motor
int MotorLeftip1=4;
int MotorLeftip2=2;

void setup() 
{
  pinMode(enRight, OUTPUT);
  pinMode(enLeft, OUTPUT);
  pinMode(MotorRightip1,OUTPUT);
  pinMode(MotorRightip2,OUTPUT);
  pinMode(MotorLeftip1,OUTPUT);
  pinMode(MotorLeftip2,OUTPUT);
    Dabble.begin(38400);
}

void loop() 
{
  Dabble.processInput();

  if(GamePad.isUpPressed())
  {
    //Move Forward
    digitalWrite(MotorRightip1,HIGH);
    digitalWrite(MotorRightip2,LOW);
    digitalWrite(MotorRightip1,HIGH);
    digitalWrite(MotorRightip2,LOW);
    analogWrite (enA, 150);
    analogWrite (enB, 180);
  }

  else if(GamePad.isDownPressed())
  {
    //Move back
    digitalWrite(MotorRightip1,LOW);
    digitalWrite(MotorRightip2,HIGH);
    digitalWrite(MotorRightip1,LOW);
    digitalWrite(MotorRightip2,HIGH);
    analogWrite (enA, 150);
    analogWrite (enB, 180);
  }

  else if(GamePad.isRightPressed())
  {
    //Move Right
    digitalWrite(MotorRightip1,LOW);
    digitalWrite(MotorRightip2,HIGH);
    digitalWrite(MotorRightip1,HIGH);
    digitalWrite(MotorRightip2,LOW);
    analogWrite (enA, 150);
    analogWrite (enB, 200);
  }

  else if(GamePad.isLeftPressed())
  {
    //Move Left
    digitalWrite(MotorRightip1,HIGH);
    digitalWrite(MotorRightip2,LOW);
    digitalWrite(MotorRightip1,LOW);
    digitalWrite(MotorRightip2,HIGH);
    analogWrite (enA, 200);
    analogWrite (enB, 150);
  }

  else if(GamePad.isTrianglePressed() || GamePad.isCirclePressed() || GamePad.isSquarePressed() || GamePad.isCrossPressed())
  {
    //Stop
    digitalWrite(MotorRightip1,LOW);
    digitalWrite(MotorRightip2,LOW);
    digitalWrite(MotorRightip1,LOW);
    digitalWrite(MotorRightip2,LOW);
    analogWrite (enA, 0);
    analogWrite (enB, 0);
  }
  else if(GamePad.isStartPressed() || GamePad.isSelectPressed())
  {
    //Move Forward
    digitalWrite(MotorRightip1,HIGH);
    digitalWrite(MotorRightip2,LOW);
    digitalWrite(MotorRightip1,HIGH);
    digitalWrite(MotorRightip2,LOW);
    analogWrite (enA, 150);
    analogWrite (enB, 180);
  }

  else
  {
    ;
  }
}

Credits

Saher Iqbal

Saher Iqbal

2 projects • 7 followers

Comments