Controlling a DC Motor with an IR Remote Controller Using Arduino and L293D

Video thumbnail for Remote 3: Controlling DC motor with IR Remote controller using Arduino and L293D RJT117

Controlling a DC Motor with an IR Remote Controller Using Arduino and L293D

This project demonstrates how to control a DC motor's direction and speed using an infrared (IR) remote, an Arduino Uno, and an L293D motor driver chip. This setup allows for precise control of the motor, making it suitable for a variety of applications.

This project opens up a world of possibilities for your DIY electronics endeavors. Here are a few ideas to get you started:

  • Remote Controlled Robot: Control the movement of a small robot using an IR remote.
  • Automated Curtain System: Open and close curtains or blinds remotely.
  • Interactive Art Installations: Create dynamic art pieces with moving parts controlled by an IR remote.
  • Pan and Tilt System: Control the pan and tilt of a camera or sensor using an IR remote.

Hardware/Components

  • Arduino Uno
  • L293D Motor Driver IC
  • DC Motor
  • IR Remote and Receiver
  • Diodes (1N4001 x4)
  • Connecting Wires
  • Power Supply (e.g., 9V battery for the motor)

Wiring Guide

%%WIRING%%

(in video at 02:14)

The L293D chip requires connections to both the Arduino and an external power supply for the motor. Diodes are used for flyback protection. The IR receiver connects to the Arduino's 5V and GND pins, with the signal pin connected to digital pin 11 (configurable in the code). The motor connects to the output pins of the L293D, which are controlled by the Arduino.

Code Explanation

(in video at 07:30)

The provided Arduino code utilizes the IRremote library to decode signals from the IR remote. The crucial configurable parameters within the code include:


const char type ='B';// W for white, B for black. Must keep single quotes like 'B' or 'W'
const boolean PCB = 0;// if receiver is PCB set to 1, if not set to 0. See video for details

Set the type variable to 'W' for a white remote or 'B' for a black remote (in video at 07:41). The PCB variable should be set to 1 if your IR receiver has a PCB, and 0 if it's a bare module (in video at 07:50).


const String RIGHT=">";// move motor to the right (CW) with this key on remote
const String LEFT ="<";// move motor to the left (CCW) with this key on remote
const String STOP ="OK";// stop motor with this key on remote

These lines define the IR remote button labels for controlling the motor. Ensure these match the labels on your remote (in video at 08:12). You can customize these to use different buttons on your remote.


#define P1A 2 // define pin 2 as for P1A
#define P2A 7 // define pin 7 as for P2A
#define EN12 8 // define pin 8 as for 1,2EN enable
int RECV_PIN = 11;

These lines define the Arduino pins used to control the L293D motor driver (in video at 09:52). P1A and P2A control the direction, and EN12 enables the motor. RECV_PIN is the pin connected to the IR receiver's signal output (in video at 06:52). Modify these if you are using different pins.

Live Project/Demonstration

(in video at 14:15)

The video demonstrates the project in action, showing how the DC motor responds to the IR remote commands. The demonstration shows how to control the motor's clockwise and counter-clockwise rotation and how to stop the motor using different remote control buttons.

Chapters

  • [00:00] Introduction and Project Overview
  • [00:53] Project Components and Prerequisites
  • [02:14] Wiring Explanation
  • [07:30] Code Explanation and Configuration
  • [14:15] Project Demonstration with Black Remote and PCB
  • [16:04] Demonstration with Silver Remote and PCB
  • [17:42] Demonstration with Silver Remote and Bare Module
  • [18:23] Demonstration with Black Remote and Bare Module

Code Snippets

Comments will be displayed here.