<aside> 📢
In this Lab you will learn how to use your mobile phone to control a DC motor though WIFI
1de3b4b677550b4139ba3ebe9a4f33a9.mp4
</aside>
Download the newest Arduino IDE.
Bring a power bank and a type C wire so the power bank can be used to power up the board.
Bring another type C wire for upload the script from your PC to the board.
A DC (Direct Current) motor is an electromechanical device that converts electrical energy into mechanical energy. It operates on the principle of electromagnetic induction, where the interaction between electrical current flowing through motor windings and a magnetic field creates rotational motion. The motor consists of key components including the stator (which contains permanent magnets or electromagnets), the rotor (or armature) with wire windings, the commutator (which reverses current direction), and brushes (that transfer electrical power to the commutator). When DC voltage is applied, the electromagnetic interaction causes the rotor to spin continuously. The speed and direction of rotation can be controlled by varying the voltage magnitude and polarity, respectively.


An H-bridge is a fundamental electronic circuit that enables bidirectional control of DC motors. It consists of four switching elements (typically transistors or MOSFETs) arranged in an "H" configuration. When different pairs of switches are activated, current can flow through the motor in either direction, allowing the motor to rotate clockwise or counterclockwise. The H-bridge also enables motor braking by shorting the motor terminals or letting the motor coast by leaving all switches open. This versatile circuit is essential in robotics, automotive applications, and any system requiring precise motor control.
The L298N module, shown in the diagram, is a popular H-bridge motor driver that can control two DC motors independently. It includes protection circuits and can handle motors operating at different voltage levels, making it ideal for educational and hobbyist projects.


In-Depth: Interface L298N DC Motor Driver Module with Arduino
A microcontroller is a compact integrated circuit that combines a processor core, memory, and programmable input/output peripherals on a single chip. It's designed to execute specific tasks in embedded systems, making it ideal for controlling electronic devices and systems. Microcontrollers are characterized by their low power consumption, small size, and ability to operate in real-time applications.
Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards use various microcontrollers, with the most common being the ATmega series. They are particularly popular in educational and hobbyist contexts due to their simple programming interface, extensive library support, and large community. Arduino provides a user-friendly integrated development environment (IDE) and a simplified version of C++ for programming, making it an excellent choice for beginners in electronics and programming.

STM32 is a family of 32-bit microcontrollers developed by STMicroelectronics based on the ARM Cortex-M processor. These microcontrollers offer higher performance, more advanced peripherals, and greater processing capabilities compared to basic Arduino boards. STM32 microcontrollers are widely used in professional and industrial applications due to their reliability, extensive feature set, and competitive pricing. They support various development environments and programming languages, though they generally require more technical expertise to utilize effectively.

ESP32 is a powerful, low-cost microcontroller with integrated Wi-Fi and Bluetooth capabilities, developed by Espressif Systems. It features a dual-core processor, extensive peripheral support, and robust wireless connectivity options, making it ideal for Internet of Things (IoT) projects. The ESP32's combination of processing power, wireless capabilities, and affordable price point has made it increasingly popular for both hobbyist projects and commercial IoT applications. It can be programmed using various platforms, including the Arduino IDE, and supports multiple programming frameworks.

| Feature | Arduino | ESP32 (What we are using) | STM32 |
|---|---|---|---|
| Processor | 8-bit ATmega (Most common) | 32-bit Dual-Core Xtensa LX6 | 32-bit ARM Cortex-M |
| Clock Speed | 16-20 MHz | Up to 240 MHz | Up to 480 MHz |
| Wireless | None (requires add-on) | Built-in WiFi & Bluetooth | None (requires add-on) |
| Memory | 2-8KB RAM, 32KB Flash | 520KB RAM, 4MB Flash | Up to 512KB RAM, 2MB Flash |
| Ease of Use | Very Easy | Moderate | Complex |
| Cost | Low | Low | Moderate |
| Best For | Beginners, Basic Projects | IoT Projects, Wireless Applications | Industrial, Professional Use |
| Programming | Arduino IDE, Simple C++ | Arduino IDE, ESP-IDF, Multiple Frameworks | Multiple IDEs, C/C++ |
An IoT (Internet of Things) platform is a comprehensive software solution that enables the connection, management, and control of various internet-connected devices. It serves as a central hub that facilitates communication between hardware devices, user applications, and data storage systems. IoT platforms typically provide essential features such as device connectivity and management, data collection and analysis, security protocols, and user interface tools. For example, these platforms allow users to remotely monitor and control devices, collect sensor data in real-time, and create automated responses based on predefined conditions. In the context of motor control, an IoT platform can provide a user-friendly interface through mobile applications, enabling users to control motor parameters like speed and direction from anywhere with an internet connection. This technology bridges the gap between physical hardware and digital control systems, making it possible to implement sophisticated control schemes with relatively simple hardware setups.
Blynk: a low-code IoT software platform for businesses and developers
