Ujjwal_Rathore
Published © LGPL

Wi-Fi Controlled Rover

The motion of robot controlling via internet is one of the easy means as it requires the user to access the designated webpage to guide it.

BeginnerFull instructions provided1,562
Wi-Fi Controlled Rover

Things used in this project

Hardware components

DC Motor
×1
Nodemcu Motor Shield
×1

Software apps and online services

WiFi Robot Controller

Story

Read more

Custom parts and enclosures

Body frame

Schematics

image

Circuit Di gram

Code

Code 1

C/C++
Output-2
Output-2
Output-1
After the connection you will copy and paste this code in Arduino IDE. Than go to the mobile phone and connect with wifi (“My_Robot”) and password(“iamnotarobot”).Than open the app in your mobile phone and set the IP address is mention in your code .If you press forward button the left motor move forward direction and the right motor move backward direction .If you press the left button the left motor move forward direction and the right motor move backward direction and so on.And you will see that all the given command it will show in status button of the app.

If you press the accelerate controller button, the movement of your mobile phone will rotate the connected motors. The motors will move in left, right, backward, forward direction according to the movements of your mobile phone. The other buttons will not work, when the accelerate Controller is ON.
/* Create a WiFi access point and provide a web server on it to receive command to control motor. */

#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <ESP8266WebServer.h>

/* Set these to your desired credentials. */
const char *ssid = "My_Robot";
const char *password = "iamnotarobot";

ESP8266WebServer server(80);

/* Just a little test message.  Go to http://192.168.4.1 in a web browser
 * connected to this access point to see it.
 */
void handleRoot() {
  server.send(200, "text/plain", "hello from Robot!");
}

void motor_forward(){
    digitalWrite(16, 1);
    digitalWrite(5, 0);
    digitalWrite(4, 1);
    digitalWrite(0, 0);
  }
void motor_stop(){
    digitalWrite(16, 0);
    digitalWrite(5, 0);
    digitalWrite(4, 0);
    digitalWrite(0, 0);
  }
void motor_back(){
    digitalWrite(16, 0);
    digitalWrite(5, 1);
    digitalWrite(4, 0);
    digitalWrite(0, 1);
  }

void motor_left(){
    digitalWrite(16, 0);
    digitalWrite(5, 1);
    digitalWrite(4, 1);
    digitalWrite(0, 0);
  }
void motor_right(){
    digitalWrite(16, 1);
    digitalWrite(5, 0);
    digitalWrite(4, 0);
    digitalWrite(0, 1);
  }


void setup() {
  // prepare Motor Output Pins
  pinMode(16, OUTPUT);
  digitalWrite(16, 0);
  
  // prepare GPIO5 relay 1
  pinMode(5, OUTPUT);
  digitalWrite(5, 0);
  
  pinMode(4, OUTPUT);
  digitalWrite(4, 0);
  
  pinMode(0, OUTPUT);
  digitalWrite(0, 0);

  
	delay(1000);
	Serial.begin(115200);
	Serial.println();
	Serial.print("Configuring access point...");
	/* You can remove the password parameter if you want the AP to be open. */
	WiFi.softAP(ssid, password);

	IPAddress myIP = WiFi.softAPIP();
	Serial.print("AP IP address: ");
	Serial.println(myIP);

 
	server.on("/", handleRoot);
 
  server.on("/inline", []() {
    server.send(200, "text/plain", "this works as well");
  });

  server.on("/fw", []() {
    motor_forward();
    server.send(200, "text/plain", "Forward");
  });
  server.on("/bk", []() {
    motor_back();
    server.send(200, "text/plain", "Back");
  });

  server.on("/st", []() {
    motor_stop();
    server.send(200, "text/plain", "Stop");
  });
  server.on("/lt", []() {
    motor_left();
    server.send(200, "text/plain", "Left");
  });
  server.on("/rt", []() {
    motor_right();
    server.send(200, "text/plain", "Right");
  });

	server.begin();
	Serial.println("HTTP server started");


  
}

void loop() {
	server.handleClient();
}

Code 2

C/C++
Output-2
After the connection you will copy and paste this code in Arduino IDE. Write the correct ssid and password. Then upload the code. Open the serial monitor.Now, you are connected with your wifi and it display the IP address on serial monitor.


Then open the app and set the IP address .If you press forward button the left motor will moves in forward direction and the right motor will moves in backward direction .If you press the backward button, then the right motor moves in forward direction and the left motor moves in backward direction and so on. And you will see that all the given command it will show in status button of the app.

When you press the accelerate controller the button is on .The movement of your mobile phone will rotate the connected motors.


Note:-When you open this app the mobile phone data connection is must be off
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

const char* ssid = "your_network_ssid";
const char* password = "your_network_password";

ESP8266WebServer server(80);

void handleRoot() {
  server.send(200, "text/plain", "hello from Robot!");
}

void motor_forward(){
    digitalWrite(16, 1);
    digitalWrite(5, 0);
    digitalWrite(4, 1);
    digitalWrite(0, 0);
  }
void motor_stop(){
    digitalWrite(16, 0);
    digitalWrite(5, 0);
    digitalWrite(4, 0);
    digitalWrite(0, 0);
  }
void motor_back(){
    digitalWrite(16, 0);
    digitalWrite(5, 1);
    digitalWrite(4, 0);
    digitalWrite(0, 1);
  }

void motor_left(){
    digitalWrite(16, 0);
    digitalWrite(5, 1);
    digitalWrite(4, 1);
    digitalWrite(0, 0);
  }
void motor_right(){
    digitalWrite(16, 1);
    digitalWrite(5, 0);
    digitalWrite(4, 0);
    digitalWrite(0, 1);
  }

void setup(void){

  // prepare Motor Output Pins
  pinMode(16, OUTPUT);
  digitalWrite(16, 0);
  
  // prepare GPIO5 relay 1
  pinMode(5, OUTPUT);
  digitalWrite(5, 0);
  
  pinMode(4, OUTPUT);
  digitalWrite(4, 0);
  
  pinMode(0, OUTPUT);
  digitalWrite(0, 0);
  
  
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  if (MDNS.begin("esp8266")) {
    Serial.println("MDNS responder started");
  }

  server.on("/", handleRoot);

  server.on("/fw", []() {
    motor_forward();
    server.send(200, "text/plain", "Forward");
  });
  server.on("/bk", []() {
    motor_back();
    server.send(200, "text/plain", "Back");
  });

  server.on("/st", []() {
    motor_stop();
    server.send(200, "text/plain", "Stop");
  });
  server.on("/lt", []() {
    motor_left();
    server.send(200, "text/plain", "Left");
  });
  server.on("/rt", []() {
    motor_right();
    server.send(200, "text/plain", "Right");
  });

  server.begin();
  Serial.println("HTTP server started");
}

void loop(void){
  server.handleClient();
}

Credits

Ujjwal_Rathore

Ujjwal_Rathore

0 projects • 1 follower

Comments