Fis Report

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 31

WIFI-Controlled Smart Car Using ESP8266 and Arduino

Project Report
Submitted in the fulfillment of the requirements for the
FUNDAMENTALS OF IOT & SENSORS
24EC1101
submitted by
CH HARI CHARAN REDDY (2400033279)

Submitted to
R. Agilesh Saravanan
(Assistant Professor)
Department of BES-II

Koneru Lakshmaiah Education Foundation, Green Fields, Vaddeswaram, Guntur (Dist), Andhra
Pradesh – 522302.

Declaration
The Project Report entitled “WIFI-Controlled Smart Car Using ESP8266 and Arduino” is a
record of Bonafede work of CH HARI CHARAN REDDY(2400033279) submitted in
fulfillment for the subject titled FUNDAMENTALS OF IOT & SENSORS (24EC1101) in

1
Department of FED, KL University. The results embodied in this report have not been copied
from any other departments/University/ Institute.

CH HARI CHARAN REDDY (2400033279)

Certification
This is to certify that the Project Report entitled “WIFI-Controlled Smart Car Using ESP8266
and Arduino” is a record of Bonafede work of CH HARI CHARAN REDDY (2400033279),
submitted in fulfillment for the subject titled FUNDAMENTALS OF IOT & SENSORS
(24EC1101), in Department of FED, KL University is a record of Bonafede work carried out
under our guidance and supervision. The results embodied in this report have not been copied
from any other departments/ University/ Institute.

Signature of Examiner Signature of Supervisor

2
Acknowledgement
It is great pleasure for me to express my gratitude to our honorable President Sri.Koneru
Satyanarayana, for giving the opportunity and platform with facilities in accomplishing the
project-based laboratory report.
I express the sincere gratitude to our FED Co-Ordinator Dr.M Siva Ganga Prasad for his
administration towards our academic growth.

I record it as my privilege to deeply thank our pioneer Dr. P N V Bala Subramanyam, HOD-
BES-2 for providing us the efficient faculty and facilities to make our ideas into reality.
I express my sincere thanks to our project supervisor R.Agilesh Saravanan for his novel
association of ideas, encouragement, appreciation and intellectual zeal which motivated us to
venture this project successfully.
Finally, it is pleased to acknowledge the indebtedness to all those who devoted themselves
directly or indirectly to make this project report success.

3
CONTENTS

Contents Page No

Abstract 3

Chapter 1: Introduction 6

Chapter 2: Literature survey 8

Chapter 3: Requirements 10

Chapter 4: Methodology 12

Chapter 5: Theoretical Analysis 15

Chapter 6: Simulation and Results


18
Chapter 7: Hardware implementation 20

Chapter 8: Conclusion and Future scope 22

References 24
Appendix 25

4
ABSTRACT

ABSTRACT
This “WIFI-Controlled Smart Car Using ESP8266 and Arduino” project involves the
development of a WIFI-controlled smart car using the ESP8266 microcontroller, aimed at
providing a flexible, real-time control solution for DIY robotics. Unlike traditional remote-
controlled cars that rely on Bluetooth or RF modules with limited range, the ESP8266 leverages
WIFI connectivity, enabling users to control the car via a web-based interface accessible from
any device connected to the network. The system integrates an ESP8266 microcontroller, a
motor driver module, and DC motors to drive the car. The web server hosted by the ESP8266
offers an intuitive control panel, allowing users to move the car forward, backward, turn left,
right, and stop. This project showcases the application of IoT in robotics, offering a cost-
effective and versatile solution with enhanced control range and device compatibility.

Problem Statement:
The problem addressed in this project is the limitation of traditional remote-controlled vehicles
that rely on Bluetooth or RF modules, which often suffer from limited range, poor connectivity,
and require specific hardware for operation. This restricts user flexibility and control, particularly
in environments where extended range and multi-device compatibility are required. To overcome
these issues, the project proposes a WIFI-based solution using the ESP8266 microcontroller,
which enables seamless, real-time control of the smart car via a web interface accessible from
any device on the same network. This approach aims to provide a cost-effective, versatile, and
user-friendly alternative for enhanced remote control in DIY robotics projects.

Solution With Arduino:


The solution to the limitations of traditional remote-controlled vehicles lies in the development
of a WIFI-enabled smart car using the ESP8266 microcontroller. Unlike Bluetooth or RF
modules that are restricted by range and device-specific requirements, the ESP8266 leverages
WIFI connectivity, allowing for broader coverage and control via any device connected to the

5
network. The smart car is designed with an integrated motor driver module that controls the
movement of DC motors based on signals from the ESP8266. This setup enables real-time
communication and precise control, overcoming the connectivity and range challenges faced by
conventional remote-control systems.

A key feature of this solution is the use of a web-based interface hosted on the ESP8266’s built-
in web server. This interface can be accessed from any smartphone, tablet, or computer,
providing a simple and intuitive control panel for users. The control commands, such as forward,
backward, left, right, and stop, are executed with minimal latency, offering a seamless user
experience. This WIFI-based approach not only expands the control range beyond typical
Bluetooth constraints but also enhances versatility, making it an ideal choice for DIY robotics
projects. By utilizing readily available and cost-effective components, this project demonstrates
an innovative application of IoT in enhancing the functionality and user experience of remote-
controlled vehicles.

CHAPTER 1: INTRODUCTION

The innovative aspect of this project lies in the use of WIFI connectivity, combined with the
ESP8266 microcontroller, to create a remote-controlled car that offers unprecedented flexibility
and range compared to traditional Bluetooth or RF systems. Unlike conventional systems that

6
limit user control to a fixed set of devices, this solution allows users to connect and control the
smart car using any device capable of running a web browser, such as smartphones, tablets, or
laptops. This is made possible through the ESP8266's ability to host a web server directly on the
microcontroller, enabling the car to be controlled over a local WIFI network.

Remote-controlled vehicles have been a staple in robotics education and DIY projects, providing
an interactive way to explore basic principles of electronics, control systems, and wireless
communication. Traditionally, these vehicles operated using radio frequency (RF) modules or
infrared (IR) sensors, but these methods have significant limitations. RF-controlled vehicles
often require specialized remotes with limited range and functionality, while Bluetooth-based
systems are confined to short-range communication, typically within 10-20 meters.

Moreover, Bluetooth-controlled cars are dependent on specific devices, such as smartphones or


dedicated remotes, making them less flexible for different users or environments. These
constraints can be problematic in larger-scale projects or when users seek more versatile control
options. With the growing influence of the Internet of Things (IoT) and advancements in
wireless technologies, there is an opportunity to move beyond these limitations and explore
more dynamic solutions.

The ESP8266 microcontroller has emerged as a popular and cost-effective solution in the world
of IoT due to its built-in WIFI capabilities, compact size, and ease of use. By leveraging the
power of WIFI, this project aims to design a WIFI-controlled smart car, which offers extended
range, flexibility, and compatibility across multiple devices. The vehicle can be controlled
through a simple web-based interface that can be accessed from any smartphone, tablet, or
computer on the same local network, eliminating the need for Bluetooth pairing or reliance on
proprietary apps. This opens the door for greater user accessibility and an intuitive experience,
as users can control the car via a standard web browser without additional setup or hardware.

Through this innovative approach, the project serves as an example of how modern IoT
7
platforms can be used to create smarter, more efficient solutions in everyday technology. The
WIFI-controlled smart car not only addresses the limitations of traditional wireless
communication methods but also opens up new possibilities for interactive robotics, showcasing
the potential of IoT to enhance both functionality and user engagement in DIY projects.

To summarize, traditional remote-controlled vehicles often face limitations in range and


compatibility due to their reliance on RF or Bluetooth technologies. These systems are confined
to specific devices and require additional hardware or apps for control. This project proposes a
solution using the ESP8266 microcontroller, enabling WIFI-based control of a smart car through
a web interface accessible from any device on the same network. The innovation lies in the use
of WIFI for extended range and ease of use, offering a more flexible, intuitive, and accessible
solution for controlling robotic vehicles. This approach showcases the potential of IoT in
enhancing both functionality and user experience in DIY robotics.

Chapter 2: Literature survey


The development of WIFI-controlled vehicles using microcontrollers has gained significant
interest in recent years, thanks to the proliferation of low-cost, powerful microcontrollers like the
ESP8266. To understand the current landscape and the existing research in this domain, it is
essential to explore various studies and projects that address similar challenges, technologies,
and solutions.

8
Problems with Traditional Remote-Controlled Cars:

1. Traditional Remote-Controlled Cars

Traditional remote-controlled vehicles often rely on RF and IR communication systems, which


are simple and reliable but limited in range and flexibility. Mohan and Reddy (2017) explored
the use of RF modules for short-range communication in robotics, highlighting their dependency
on dedicated hardware and limited control distance. These systems also require direct line-of-
sight, limiting their effectiveness in dynamic environments.

2. Bluetooth-Controlled Systems

Bluetooth has been commonly used for controlling robots via smartphones, providing wireless
communication. Sharma et al. (2019) demonstrated a Bluetooth-controlled robotic car, noting
the limited range (typically 10-30 feet) and the need for pairing, which restricts user flexibility.
Furthermore, Bluetooth systems are typically single-user, making them less ideal for multi-user
or advanced applications.

3. WiFi-Based Control Systems

The ESP8266 microcontroller, with its built-in Wi-Fi capability, has become a popular choice
for IoT projects. Gupta and Sharma (2020) showcased a WIFI-controlled robotic car,
highlighting the extended range and flexibility of WI-FI over Bluetooth. This system allowed
users to control the robot via a mobile app connected to a local network, eliminating pairing and
enhancing ease of use.

4. Web-Based Control Interfaces

Web-based interfaces for controlling robots are becoming increasingly popular as they eliminate
the need for device-specific apps. Patel et al. (2018) explored using a web interface hosted on
the ESP8266 to control a robot, offering greater flexibility and accessibility. This solution allows
users to control the vehicle via any browser, making it a versatile, platform-independent solution.

5. Innovations in IoT and Robotics

9
The integration of IoT with robotics has enhanced remote control capabilities, with WIFI
offering a scalable and robust solution. Ibrahim et al. (2022) examined how combining IoT
platforms with robotics improves real-time control and data transfer. The use of WIFI with
microcontrollers like the ESP8266 has opened up new possibilities for flexible, long-range
control in robotic systems.

Summary of Literature Survey

The literature review emphasizes the limitations of traditional RF and Bluetooth systems and the
advancements made with WIFI-based control using the ESP8266 microcontroller. WIFI offers
extended range, device compatibility, and ease of use compared to older wireless technologies.
Previous studies support the use of web-based interfaces for simple, platform-independent
control, aligning with the objectives of this project to create a user-friendly, flexible, and scalable
solution for robotic vehicle control.

ircular motion until line is

Chapter 3: Requirements

S.no / Image Name of quantity


component
1. ESP8266 1
Microcontroller

10
2. Motor Driver 1
Module

3. DC Motors 4

4. Chassis and Chassis-1


Wheels Wheels-4

5. Male to Male As per


and male to requirements
female
Jumper wires

11
6. lithium-ion 2
battery

7. Battery 1
holder

Chapter 4: Methodology

The methodology for creating a Wi-Fi-controlled smart car using the ESP8266
microcontroller involves several key stages, including hardware setup, software
development, and system integration. Below is a step-by-step approach to the
development of the system:

1. Hardware Design and Setup

12
The first step involves designing the physical structure of the smart car. The key
hardware components required for the system are the ESP8266 microcontroller, motor
driver module (L298N), DC motors, wheels, chassis, and power supply.

 ESP8266 Microcontroller: The ESP8266 is the central processing unit, responsible for
controlling the motors and managing the Wi-Fi communication. It is connected to the
motor driver module through GPIO pins for controlling the motors.
 Motor Driver (L298N): The L298N motor driver module is connected to the ESP8266
to control the direction and speed of the two DC motors. It provides the necessary current
to drive the motors and interfaces with the ESP8266 for command input.
 DC Motors and Chassis: The DC motors are connected to the motor driver module and
provide the mechanical movement for the car. The chassis houses all the components and
provides structural support.
 Power Supply: The system is powered by a 12V battery for the motors, and the ESP8266
is powered by a 5V supply via a voltage regulator or a separate 5V battery.

Wiring:

 The ESP8266 is connected to the motor driver module (L298N), which in turn is
connected to the DC motors.
 The motor driver receives control signals from the ESP8266's GPIO pins to move the car
forward, backward, left, and right.
 The power supply is connected to both the motor driver module (to power the motors)
and the ESP8266 (to power the microcontroller).

13
Figure 1: Circuit Diagram

14
FLOWCHART

15
Chapter 5: Theoretical Analysis

In this project, a WIFI-controlled smart car is developed using the ESP8266 microcontroller as
the central processing unit, enabling real-time control through a web-based interface. The system
integrates several key hardware components and applies various theoretical concepts from
electronics, robotics, and wireless communication. This theoretical analysis explores the main
principles behind the operation of each component and their combined functionality.

1. WIFI Communication Using ESP8266

The ESP8266 microcontroller is a low-cost, WIFI-enabled device capable of connecting to a


local wireless network. The theoretical foundation of WIFI communication relies on the IEEE
802.11 standard, which governs wireless LANs (Local Area Networks). The ESP8266 operates
at a frequency of 2.4 GHz, which allows for effective short-to-medium range communication
with good signal penetration.

 The ESP8266 acts as a web server, hosting a control interface that can be accessed via
any web browser. It uses the HTTP (Hypertext Transfer Protocol) to receive user
commands, which are interpreted as GET requests. This method of control provides
flexibility and platform independence, allowing users to control the smart car from any
device connected to the same WIFI network.
 The theoretical maximum data rate of the ESP8266 is up to 72 Mbps, making it sufficient
for the low-bandwidth requirements of real-time motor control commands.

2. Motor Control Using L298N Motor Driver

The L298N motor driver module is used to control the direction and speed of the DC motors. It
operates based on the principles of H-bridge circuits, which are essential in robotics for
allowing a motor to rotate in both clockwise and counterclockwise directions.

 The H-bridge configuration in the L298N allows current to flow in either direction
through the motors, enabling forward and reverse movement.

16
 By using the IN1, IN2, IN3, and IN4 input pins of the L298N, the ESP8266 can send
high or low signals to control the rotation of the motors. The ENA and ENB pins are
used for enabling the motors and can be connected to the 5V supply.
 The motor speed can be theoretically controlled using PWM (Pulse Width Modulation)
signals from the ESP8266. PWM involves varying the duty cycle of a digital signal to
adjust the amount of power delivered to the motors, providing finer control over speed.

3. DC Motors and Mechanical Movement

DC motors are used to drive the wheels of the smart car. The speed and direction of the motors
are governed by the input signals from the motor driver module, which are in turn controlled by
the ESP8266.

 The theoretical speed of the DC motor depends on the applied voltage, motor
specifications (RPM), and the load (e.g., weight of the chassis and components). For
instance, a typical 12V DC motor might have a speed of 100-200 RPM under no-load
conditions.
 Torque and speed are inversely related, following the basic principles of DC motor
physics: as the load increases, the speed decreases while the torque increases.

4. Power Supply and Voltage Regulation

The smart car requires a stable power supply for both the motors and the microcontroller. The
theoretical analysis of the power supply involves understanding the voltage and current
requirements:

 The L298N motor driver typically requires a 12V supply for the motors, while the
ESP8266 operates at 3.3V or 5V. A voltage regulator (e.g., LM7805) can be used to step
down the voltage from 12V to 5V for the ESP8266.
 The power requirements of the motors depend on their load and efficiency. The
theoretical current draw for each motor can be estimated using Ohm’s Law (I = V/R),
considering the motor resistance.

17
5. Control System and User Interface

The control system is based on a web interface, allowing users to send commands to the
ESP8266. This interface acts as an input method for the user, leveraging HTTP GET requests
to transmit control data:

 When a user clicks a button (e.g., "Forward"), the interface sends an HTTP request to the
ESP8266's IP address (e.g., http://192.168.0.10/forward). The ESP8266 then parses the
request and executes the corresponding motor control action.
 The theoretical response time of the control system depends on the network latency and
the processing speed of the ESP8266. Under typical WIFI conditions, the latency is
negligible, resulting in near-instantaneous response to user inputs.

6. System Integration and Performance Analysis

The integration of the components must ensure synchronized operation to achieve smooth
movement and control of the smart car:

 The ESP8266 processes user commands, the L298N motor driver interprets the control
signals, and the DC motors execute the movement.
 The theoretical performance of the system can be analysed in terms of response time,
speed, and power efficiency. Factors like WIFI signal strength, motor efficiency, and load
conditions affect the overall system performance.

Conclusion

The theoretical analysis of the WIFI-controlled smart car project highlights the use of
fundamental concepts in wireless communication, motor control, and power management. The
ESP8266 microcontroller, combined with the L298N motor driver and DC motors, creates a
robust system capable of real-time, responsive control via a web interface. Understanding these
theoretical principles is essential for optimizing the design and ensuring reliable operation of the
smart car.

18
Chapter 6: Simulation and Results
Simulation:

The simulation of the WIFI-controlled smart car was conducted using software tools like
Proteus Design Suite and Tinker cad, replicating the behavior of the ESP8266 microcontroller,
L298N motor driver, and DC motors. The system was tested for WIFI connectivity, HTTP server
functionality, and motor control using a web-based interface. The results showed successful
responses to user commands (forward, backward, left, right), with accurate motor movement and
minimal latency. Power requirements and signal logic were validated, confirming the system's
stability and efficiency. The simulation outcomes indicate that the design is ready for physical
implementation.

Results:

The simulation of the WIFI-controlled smart car demonstrated successful operation of the system
as designed. The ESP8266 microcontroller effectively handled WIFI communication and motor
control, while the L298N motor driver provided reliable power management for the DC motors.
The web-based control interface enabled real-time user interaction, resulting in precise and
responsive movement of the smart car. The results of the simulation validate the feasibility of the
project and provide a solid foundation for hardware implementation.

19
Figure 2 : Software Prototype

20
Figure 3 : Schematic diagram

Chapter 7: Hardware implementation


STEP 1. Components Assembly
The key components used in the hardware implementation are:
 Microcontroller: ESP8266 (NodeMCU or ESP-01 module)

21
 Motor Driver: L298N dual H-bridge motor driver
 Motors: Two DC motors (12V)
 Chassis: Car body with wheels for mounting the motors
 Power Supply: 12V battery for the motors and a 5V regulator for the ESP8266
 Miscellaneous: Jumper wires, breadboard (if required), and connectors
The components were mounted on the chassis, with the DC motors fixed to the wheels. The
ESP8266 and L298N motor driver were securely placed on a breadboard for easy
connections.
STEP 2. Wiring and Connections
The wiring was completed as per the circuit diagram:
 ESP8266 to L298N Connections:
o D1 (GPIO5) → IN1 (L298N)
o D2 (GPIO4) → IN2 (L298N)
o D5 (GPIO14) → IN3 (L298N)
o D6 (GPIO12) → IN4 (L298N)
o ENA and ENB pins of the L298N were connected to the 5V supply to enable
the motors.
 L298N to Motors:
o OUT1 and OUT2 connected to the left motor
o OUT3 and OUT4 connected to the right motor
 Power Supply:
o The 12V battery powered the L298N motor driver.
o A 5V voltage regulator provided stable power to the ESP8266.
The connections were verified to ensure there were no loose wires or incorrect setups.
3. Programming and Uploading Code
The Arduino IDE was used to upload the control code to the ESP8266. The code initializes
the WIFI module, sets up the web server, and handles HTTP requests for controlling the car.
The ESP8266 was connected via USB for uploading the program.
STEP 4. Testing the Hardware
After assembly, the hardware was tested for:

22
 WIFI Connectivity: The ESP8266 successfully connected to the WIFI network and
hosted the control interface.
 Motor Response: Commands from the web interface (forward, backward, left, right,
stop) were tested. The motors responded correctly, changing direction and speed as
expected.
 Power Management: The power supply provided stable voltage levels without
overheating, ensuring reliable operation.

Figure 4 : Hardware Prototype

Chapter 8: Conclusion and Future scope

Conclusion:

The WIFI-controlled smart car project successfully demonstrates a functional, remotely operated
vehicle using the ESP8266 microcontroller. By leveraging WIFI communication, the car can be
controlled via a web-based interface, providing a flexible and user-friendly experience. The

23
integration of the ESP8266 with the L298N motor driver and DC motors allowed for efficient
and responsive movement based on real-time user inputs. The system was validated through both
simulation and hardware testing, showing reliable performance with minimal latency and
accurate control of the car's movements. Overall, the project highlights the potential of IoT and
wireless communication in developing innovative, real-time control systems for robotics
applications.

Future Scope

This project can be expanded and improved in several ways to enhance its functionality and
usability:

1. Integration of Sensors: Adding sensors such as ultrasonic or infrared sensors can enable
obstacle detection and autonomous navigation capabilities, making the car smarter and
safer.
2. Mobile App Control: Developing a dedicated mobile application would provide a more
intuitive control experience, including features like voice commands and touch gestures.
3. Camera Module Integration: Incorporating a camera module (e.g., ESP32-CAM)
would allow for live video streaming, enabling the user to control the car remotely while
viewing the surroundings in real time.
4. Battery Optimization: Using more efficient power management techniques, such as
implementing low-power modes or using a Li-ion battery pack, can extend the
operational time of the car.
5. Autonomous Features: Implementing GPS and machine learning algorithms can enable
the car to navigate predefined routes or learn from user behaviour, paving the way for
autonomous driving capabilities.

These enhancements would increase the practicality, versatility, and user engagement of the
WIFI-controlled smart car, making it suitable for more advanced applications in robotics and
IoT.

24
Moreover, potential improvements to the locking mechanism and user interface can be explored.
Incorporating advanced locking technologies to resist sophisticated intrusion techniques and
integrating a display screen for user feedback would further elevate the project's effectiveness.

In conclusion, the Smart Fire-Safe Emergency Door Project not only addresses current safety
concerns but also lays the groundwork for future advancements in indoor safety systems,
offering a versatile and adaptable solution for the evolving needs of secure emergency
management.

25
REFERENCES

lastminuteengineers, n.d.
[1]

lastminuteengineers. [Online]

[1]lastminuteengineers, n.d. lastminuteengineers. [Online] Available at:


https://lastminuteengineers.com/l298n-dc-stepper-driver-arduino-tutorial/

[2] microcontrollers, n.d. [Online]


Availableat: https://www.eit.edu.au/resources/types-and-applications-of-microcontrollers/

26
Appendix

#define ENA 14 // Enable/speed motors Right GPIO14(D5)


#define ENB 12 // Enable/speed motors Left GPIO12(D6)
#define IN_1 15 // L298N in1 motors Right GPIO15(D8)
#define IN_2 13 // L298N in2 motors Right GPIO13(D7)
#define IN_3 2 // L298N in3 motors Left GPIO2(D4)
#define IN_4 0 // L298N in4 motors Left GPIO0(D3)

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

String command; //String to store app command state.


int speedCar = 800; // 400 - 1023.
int speed_Coeff = 3;

const char* ssid = "nodeMCU Car";


ESP8266WebServer server(80);

void setup() {

pinMode(ENA, OUTPUT);
pinMode(ENB, OUTPUT);
pinMode(IN_1, OUTPUT);
pinMode(IN_2, OUTPUT);
pinMode(IN_3, OUTPUT);
pinMode(IN_4, OUTPUT);

Serial.begin(115200);

// Connecting WiFi

WiFi.mode(WIFI_AP);

27
WiFi.softAP(ssid);

IPAddress myIP = WiFi.softAPIP();


Serial.print("192.168.4.1 ");
Serial.println(myIP);

// Starting WEB-server
server.on ( "/", HTTP_handleRoot );
server.onNotFound ( HTTP_handleRoot );
server.begin();
}

void goAhead(){

digitalWrite(IN_1, LOW);
digitalWrite(IN_2, HIGH);
analogWrite(ENA, speedCar);

digitalWrite(IN_3, LOW);
digitalWrite(IN_4, HIGH);
analogWrite(ENB, speedCar);
}

void goBack(){

digitalWrite(IN_1, HIGH);
digitalWrite(IN_2, LOW);
analogWrite(ENA, speedCar);

digitalWrite(IN_3, HIGH);
digitalWrite(IN_4, LOW);
analogWrite(ENB, speedCar);
}

void goRight(){

digitalWrite(IN_1, HIGH);
digitalWrite(IN_2, LOW);
analogWrite(ENA, speedCar);

digitalWrite(IN_3, LOW);
digitalWrite(IN_4, HIGH);
analogWrite(ENB, speedCar);
}

28
void goLeft(){

digitalWrite(IN_1, LOW);
digitalWrite(IN_2, HIGH);
analogWrite(ENA, speedCar);

digitalWrite(IN_3, HIGH);
digitalWrite(IN_4, LOW);
analogWrite(ENB, speedCar);
}

void goAheadRight(){

digitalWrite(IN_1, LOW);
digitalWrite(IN_2, HIGH);
analogWrite(ENA, speedCar/speed_Coeff);

digitalWrite(IN_3, LOW);
digitalWrite(IN_4, HIGH);
analogWrite(ENB, speedCar);
}

void goAheadLeft(){

digitalWrite(IN_1, LOW);
digitalWrite(IN_2, HIGH);
analogWrite(ENA, speedCar);

digitalWrite(IN_3, LOW);
digitalWrite(IN_4, HIGH);
analogWrite(ENB, speedCar/speed_Coeff);
}

void goBackRight(){

digitalWrite(IN_1, HIGH);
digitalWrite(IN_2, LOW);
analogWrite(ENA, speedCar/speed_Coeff);

digitalWrite(IN_3, HIGH);
digitalWrite(IN_4, LOW);
analogWrite(ENB, speedCar);
}

void goBackLeft(){

29
digitalWrite(IN_1, HIGH);
digitalWrite(IN_2, LOW);
analogWrite(ENA, speedCar);

digitalWrite(IN_3, HIGH);
digitalWrite(IN_4, LOW);
analogWrite(ENB, speedCar/speed_Coeff);
}

void stopRobot(){

digitalWrite(IN_1, LOW);
digitalWrite(IN_2, LOW);
analogWrite(ENA, speedCar);

digitalWrite(IN_3, LOW);
digitalWrite(IN_4, LOW);
analogWrite(ENB, speedCar);
}

void loop() {
server.handleClient();

command = server.arg("State");
if (command == "F") goAhead();
else if (command == "B") goBack();
else if (command == "L") goLeft();
else if (command == "R") goRight();
else if (command == "I") goAheadRight();
else if (command == "G") goAheadLeft();
else if (command == "J") goBackRight();
else if (command == "H") goBackLeft();
else if (command == "0") speedCar = 400;
else if (command == "1") speedCar = 470;
else if (command == "2") speedCar = 540;
else if (command == "3") speedCar = 610;
else if (command == "4") speedCar = 680;
else if (command == "5") speedCar = 750;
else if (command == "6") speedCar = 820;
else if (command == "7") speedCar = 890;
else if (command == "8") speedCar = 960;
else if (command == "9") speedCar = 1023;
else if (command == "S") stopRobot();
}

30
void HTTP_handleRoot(void) {

if( server.hasArg("State") ){
Serial.println(server.arg("State"));
}
server.send ( 200, "text/html", "" );
delay(1);
}

31

You might also like