⚙️ How to Control a DC Motor with Arduino & L298N Motor Driver – Speed & Direction

 Controlling DC motors is one of the most exciting things you can do with Arduino! In this tutorial, you’ll learn how to use the L298N motor driver to control the speed and direction of a DC motor using PWM (Pulse Width Modulation).

✅ Perfect for DIY robotics, RC cars, home automation, and mechanical systems
✅ Beginner-friendly code with step-by-step explanation
✅ Works with any standard DC motor
✅ Bonus: Download our Android app to take control from your phone!


🧰 Components Required

  • ✅ Arduino Uno (or compatible board)

  • ✅ L298N Motor Driver Module

  • ✅ DC Motor (6V–12V recommended)

  • ✅ Jumper wires

  • ✅ Power supply (Battery or Adapter)

🛒 Buy everything you need from Plysmotix.in — India’s trusted store for electronics, robotics, and DIY kits.


🧠 Understanding L298N Motor Driver

The L298N module allows you to:

  • Control the direction of a DC motor using IN1 and IN2 pins

  • Control the speed using the ENA pin with PWM signals

  • Run 2 motors simultaneously (for robotics or dual drive systems)


🔌 Wiring Diagram

L298N PinConnect to Arduino
ENAPin 9 (PWM)
IN1Pin 8
IN2Pin 7
GNDGND
VCCExternal motor power (e.g., 12V)
5VConnect to Arduino 5V (only if jumper is removed)

📱 View this wiring diagram in our Android app!
👉 Download from Play Store for interactive tutorials.


💻 Arduino Code to Control DC Motor (Speed + Direction)

// Controls the speed and direction of a DC motor using L298N int enA = 9; // PWM speed control int in1 = 8; // Direction control int in2 = 7; // Direction control void setup() { pinMode(enA, OUTPUT); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); } void loop() { // Move motor forward digitalWrite(in1, HIGH); digitalWrite(in2, LOW); analogWrite(enA, 150); // Set speed (0-255) delay(3000); // Stop motor digitalWrite(in1, LOW); digitalWrite(in2, LOW); delay(2000); // Move motor backward digitalWrite(in1, LOW); digitalWrite(in2, HIGH); analogWrite(enA, 150); delay(3000); }

🔍 Code Explanation

  • analogWrite(enA, 150); controls the motor speed

  • digitalWrite(in1, HIGH); digitalWrite(in2, LOW); moves motor forward

  • Reversing the logic (LOW, HIGH) moves it backward

  • delay() is used to pause actions for visual testing


📲 Download the Plysmotix Android App

Control your Arduino projects with your smartphone! Our app helps you:

  • Get Bluetooth-based motor control features

  • Access live wiring diagrams and tutorials

  • Buy and track orders directly from your phone

  • Save and share your own project ideas

🎯 Download now on Google Play


🚀 Real-World Projects You Can Build

  • 🤖 Line-following robot

  • 🏠 Smart curtain opener

  • 🕹️ Bluetooth-controlled RC car

  • 🔄 Conveyor belt control for automation

  • 💡 Motorized camera slider


🛍️ Buy L298N Modules, Motors & Arduino Kits Online

Why wait? Get the parts now and start building today:

🛒 Shop now at Plysmotix.in – India’s DIY electronics hub.

  • Genuine Arduino boards

  • L298N H-Bridge modules

  • Robot chassis kits

  • Power adapters, jumper wires, sensors, and more

✨ Bulk discounts available for schools, colleges & makerspaces!


💡 Tips to Expand This Project

  • Use a joystick or Bluetooth module (HC-05) for wireless control

  • Add a rotary encoder for precise motor speed monitoring

  • Control 2 motors for advanced robotics applications

Need help upgrading your project? Message us through the app!


✅ Conclusion

Learning to control DC motors with Arduino and the L298N driver is a foundational skill for robotics, automation, and creative electronics. Once you’ve mastered this, the possibilities are endless!

Start simple, experiment with speed and direction, and level up your DIY skills.


📦 Get Started Now!

  • 🛒 Buy everything you need at Plysmotix.in

  • 📲 Download our Android app for tutorials, code, and community

  • 💬 Leave a comment if you have questions—we’re here to help!

Comments

Popular posts from this blog

💡How to Blink an LED with Arduino – Beginner's Guide with Code

☢🌫 How to Control Fan Speed with Arduino Using PWM and a Potentiometer

🔊 How to Make a Buzzer Beep with Arduino – Easy Sound Project for Beginners