Internet Controlled Robot

Robot motions are controlled using android app which can provide motion control over the internet.

AdvancedProtip2 days764
Internet Controlled Robot

Things used in this project

Story

Read more

Schematics

android app

App for robot control

Code

robot motion control code

Arduino
You can use it for controlling robot motions via android app
#ifndef __CC3200R1M1RGC__
// Do not include SPI for CC3200 LaunchPad
#include <SPI.h>
#endif
#include <WiFi.h>

//define the pins to be connected to ultrasonic sensorw
//define the pins to be connected to ultrasonic sensor

#define LeftMotor1  24
#define LeftMotor2  25

#define RightMotor1 26

#define RightMotor2 27

char ssid[] = "UNKNOWN WIFI";
char password[] = "rajsinha123";

const int HTTPPORT = 80;
char * USER_AGENT = "TI";
char * VERSION = "1.0";
char * server = "industrial.api.ubidots.com";
char* TOKEN = "BBFF-fTs0egJWukQBkwDpkByYTkZI3N2WZ1"; // Put here your TOKEN

char* DEVICE_LABEL = "autobot"; // Your Device label

/* Put here your variable's labels*/
char const * VARIABLE_LABEL = "autobot";
WiFiClient client;

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(115200);

  // attempt to connect to Wifi network:
  Serial.print("Attempting to connect to Network named: ");
  // print the network name (SSID);
  Serial.println(ssid); 
  // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
  WiFi.begin(ssid, password);
  while ( WiFi.status() != WL_CONNECTED) {
    // print dots while we wait to connect
    Serial.print(".");
    delay(300);
    pinMode(LeftMotor1,  OUTPUT);

  pinMode(LeftMotor2,  OUTPUT);

  pinMode(RightMotor1, OUTPUT);

  pinMode(RightMotor2, OUTPUT);

  
  }
  
  Serial.println("\nYou're connected to the network");
  Serial.println("Waiting for an ip address");
  
  while (WiFi.localIP() == INADDR_NONE) {
    // print dots while we wait for an ip addresss
    Serial.print(".");
    delay(300);
  }

 
}


void loop() {
   if (client.connect(server, 80)) {
    client.print(F("GET /api/v1.6/devices/"));
    client.print(DEVICE_LABEL);
    client.print(F("/"));
    client.print(VARIABLE_LABEL);
    client.print(F("/lv"));
    client.print(F(" HTTP/1.1\r\n"));
    client.print(F("Host: "));
    client.print(server);
    client.print(F("\r\n"));
    client.print(F("User-Agent: "));
    client.print(USER_AGENT);
    client.print(F("/"));
    client.print(VERSION);
    client.print(F("\r\n"));
    client.print(F("X-Auth-Token: "));
    client.print(TOKEN);
    client.print(F("\r\n"));
    client.print(F("Content-Type: application/json\r\n\r\n"));
    client.println();
    
}
  String s="";
  bool a=false;
  char movement='5';
  while (client.available()) {
    char c = client.read();
    s=s+c;
    a=true;
  }

  Serial.println(s);
   movement = get_movement(s);
   Serial.println(movement);
 
  if(a==true){
      client.stop();
      a=false;
  }
 
  if(movement=='1'){    //Forward

  digitalWrite(LeftMotor1, HIGH);

  digitalWrite(LeftMotor2, LOW);

  digitalWrite(RightMotor1, HIGH);

  digitalWrite(RightMotor2, LOW);

  
  }
  else if(movement=='2'){ //Backward

  digitalWrite(LeftMotor2, HIGH);

  digitalWrite(LeftMotor1, LOW);

  digitalWrite(RightMotor2, HIGH);

  digitalWrite(RightMotor1, LOW);

    }
  else if(movement=='3'){ //left
    
  digitalWrite(LeftMotor1, HIGH);

  digitalWrite(LeftMotor2, LOW);

  digitalWrite(RightMotor1, LOW);

  digitalWrite(RightMotor2, LOW);

  }
  else if(movement=='4'){ //Right
  
  digitalWrite(LeftMotor1, LOW);

  digitalWrite(LeftMotor2, LOW);

  digitalWrite(RightMotor1, HIGH);

  digitalWrite(RightMotor2, LOW);
  }
  else if(movement=='5'){ //stop
  digitalWrite(LeftMotor1, LOW);

  digitalWrite(LeftMotor2, LOW);

  digitalWrite(RightMotor1, LOW);

  digitalWrite(RightMotor2, LOW);
  }


 
 }


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}


char get_movement(String a){
  int endi =0;
  int i;
  for(i=0;i<a.length();i++){

    if(a.charAt(i)=='\n'){
      endi++;
    }
    if(endi==10){
      break;
    }
  }
  return a.charAt(i+1);
  
}

Credits

Dr. Umesh Dutta

Dr. Umesh Dutta

38 projects • 41 followers
Working as Director of Innovation Centre at Manav Rachna, India. I am into development for the last 12 years.
Himanshu Sinha

Himanshu Sinha

2 projects • 4 followers
Deepak Rana

Deepak Rana

1 project • 0 followers
Energia

Energia

34 projects • 23 followers
Founder of @energiaproject
Texas Instruments University Program

Texas Instruments University Program

91 projects • 95 followers
TI helps students discover what's possible to engineer their future. Learn about TI tech for the classroom: www.university.ti.com

Comments

Add projectSign up / Login