Project showcase
Rover Robot Controlled by a Blynk App from a Mobile

Rover Robot Controlled by a Blynk App from a Mobile © GPL3+

The idea is to upgrade my rover to be controlled by a Blynk app in my mobile. The Blynk is talking to my Arduino UNO using Bluetooth HC06.

  • 2,153 views
  • 0 comments
  • 4 respects

Components and supplies

Apps and online services

About this project

Video

The unique issue that I have experimented is the refreshing time when you use direct Bluetooth link. If you try to create a more complete layout on the Blynk app, the rest of the code on the Arduino is delayed and it works erratically.

Therefore I added only two controls, the joystick and the Bluetooth control. The rover moves fine, and the ultrasonic sensor in front of the vehicle is used to stop the movements when the distance is too close to an obstacle.

Enjoy.

These are the steps to create a Blynk panel:

  • Open the Blynk app in your mobile.
  • Create a New Project.
  • Pickup the auth token. It will be added to your Arduino sketch.
  • Add components or controls by pressing the + on the top right.

Pictures of the Blynk app from my mobile to control the rover:

  • A list of detected Bluetooth devices will appear. Select one and press OK:

Pictures of the rover:

Code

CODEArduino
/*************************************************************
  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Blynk community:            http://community.blynk.cc
    Social networks:            http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  This example shows how to use Arduino with HC-06/HC-05
  Bluetooth 2.0 Serial Port Profile (SPP) module
  to connect your project to Blynk.

  Note: This only works on Android! iOS does not support SPP :(
        You may need to pair the module with your smartphone
        via Bluetooth settings. Default pairing password is 1234

  Feel free to apply it to any other example. It's simple!

  NOTE: Bluetooth support is in beta!

  You can receive x and y coords for joystick movement within App.

  App project setup:
    Two Axis Joystick on V1 in MERGE output mode.
    MERGE mode means device will receive both x and y within 1 message
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "65176043c54744dbb5615ff0a722898a";

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

//*************************************************************
int Trig=5;
int Echo=3;
int MARCHA;
int INA=2;
int INB=4;
int ENA=6;

int INC=7;
int IND=8;
int ENB=9;

float LMotor_offset,RMotor_offset;
float Turn_Speed = 0, Turn_Speed_K = 0;
float Run_Speed = 0, Run_Speed_K = 0, Run_Speed_T = 0;
float LOutput=0;float ROutput=0;
//Variable en la que se va a almacenar el valor correspondiente a la distancia
int Dist,Dist1,Dist2;
// APP DEL MVIL
 int x,y;

BLYNK_WRITE(V10) {
  x = param[0].asInt(); // It extracts the x value of the Joystick inlcuded in the Mobile APP Blynk
  y = param[1].asInt(); // It extracts the y value of the Joystick inlcuded in the Mobile APP Blynk
}


void setup()
{
  // Debug console
  pinMode(13,OUTPUT);
  Serial.begin(9600);
  Serial.println("FICHERO coche10_with_blynk.ino");
  delay(2000);
  SerialBLE.begin(9600);
  Blynk.begin(SerialBLE, auth);
  Serial.println("Waiting for connections...");
  pinMode (Trig, OUTPUT);
  pinMode (Echo, INPUT);
  pinMode(INA,OUTPUT);
  pinMode(INB,OUTPUT);
  pinMode(INC,OUTPUT);
  pinMode(IND,OUTPUT);
  x=0;
  y=0;
  LOutput=0;
  ROutput=0;

}

void loop()
{
  Blynk.run(); // To Run Blynk
  XY_TO_RUN_TURN_SPEEDS(); //X of the Joystick represent the turn speed and Y the RUN speed
  PWMControl();// It controls the logic for the Motors H bridge
}

void XY_TO_RUN_TURN_SPEEDS(){
if(x!=128){
    Turn_Speed=map(x,0,255,160,-160);
}else{
  Turn_Speed=0;
}
if(y!=128){
  Run_Speed=map(y,0,255,-300,300);
}else{
  Run_Speed=0;
}
  LOutput = Run_Speed + Turn_Speed;
  ROutput = Run_Speed - Turn_Speed;  
  LOutput= -LOutput;
  }

  void PWMControl(){
  if(LOutput > 0){
    digitalWrite(INA, HIGH);
    digitalWrite(INB, LOW);
  }
  else if(LOutput < 0){
    digitalWrite(INA, LOW);
    digitalWrite(INB, HIGH);
  }
  else{
    digitalWrite(INA, HIGH);
    digitalWrite(INB, HIGH);
  }
  if(ROutput > 0){
    digitalWrite(INC, HIGH);
    digitalWrite(IND, LOW);
  }
  else if(ROutput < 0){   
    digitalWrite(INC, LOW);
    digitalWrite(IND, HIGH);
  }
  else{
    digitalWrite(INC, HIGH);
    digitalWrite(IND, HIGH);
  }
    ultrasonido (Dist);
    Dist1=Dist;
    Serial.println(Dist1);
    if (Dist1>20) {
    analogWrite(ENA, min(255, abs(LOutput)));
    analogWrite(ENB, min(255, abs(ROutput)));
    }else{
       analogWrite(ENA, 0);
       analogWrite(ENB, 0);
       
      
      
    }
   
}

//Este mdulo calcula y devuelve la distancia en cm.
/*
Puedes poner el cdigo del mdulo directamente en el loop o utilizar el mdulo
para reducir el nmero de lneas de cdigo del loop o reutilizar el cdigo
*/
void ultrasonido (int &Distancia){
 
//Para estabilizar el valor del pin Trig se establece a LOW
digitalWrite (Trig, LOW);
delay(10);
 
//Se lanzan los 8 pulsos
digitalWrite (Trig, HIGH);
delay(10);
digitalWrite (Trig, LOW);
 
/*
Se mide el tiempo que tarda la seal en regresar y se calcula la distancia.
 
Observa que al realizar pulseIn el valor que se obtiene es tiempo, no distancia
 
Se est reutilizando la variable Distancia.
*/
 
Distancia= pulseIn (Echo, HIGH);
Distancia=Distancia/58;
 
delay(10);
  
}

Comments

Similar projects you might like

Robot Rover - iPhone controlled using Blynk Joystick

Project tutorial by jim Myracle

  • 4,948 views
  • 0 comments
  • 17 respects

Control Arduino Uno Using ESP8266 WiFi Module and Blynk App

Project tutorial by Adithya TG

  • 5,254 views
  • 10 comments
  • 18 respects

RC Car to BT Car Controlled with Blynk

Project tutorial by Team Daxes Hacks

  • 3,598 views
  • 2 comments
  • 6 respects
Add projectSign up / Login