Arduino based remote controlled DC motor

This topic shows how did I build a simple remote controlled DC motor (speed and direction of rotation) using an Arduino UNO board and an IR remote control. I used Car MP3 IR remote control which uses NEC protocol and a 12V DC motor.

In the previous post I made a DC motor control circuit using Arduino where a potentiometer was used to control the speed and a pushbutton to control the rotation direction, project link is below:
Arduino DC motor speed and direction control with L293D

Also, I built a decoder circuit for IR remote control with NEC protocol using Arduino because first we’ve to decode our remote control in order to know button codes (to be placed in the software code):
Arduino NEC IR remote control decoder

So before you start you have to know your remote control codes, for me I used the remote control shown below, it’s Car MP3 remote control but be careful some other Car MP3 remote controls do not have the same button codes, the best way to find these codes is through decoding it.

Car MP3 remote control

In this project I used 3 buttons and I chose: 1, 2 and 3. Button codes (in hexadecimal format) and functions are shown in the table below (NEC remote control code is 32-bit long):

Button Number Function Code
1 Change direction 0x40BF30CF
2 Speed down 0x40BFB04F
3 Speed up 0x40BF708F

Components Required:

  • Arduino UNO board
  • L293D motor driver IC
  • 12V DC motor
  • IR remote control (NEC protocol)
  • IR receiver
  • 47 uF capacitor
  • 12V source
  • Breadboard
  • Jumper wires

Arduino dc motor speed and direction control using ir remote control

Arduino remote controlled DC motor circuit:
Project circuit schematic diagram is shown below.

Arduino remote control DC motor circuit

The IR receiver is used to receive IR signal comes from the remote control, it has 3 pins: GND, VCC and OUT. It is supplied with 5V which comes from the Arduino board and its output pin is connected to Arduino uno pin 2.

The L293D is supplied with 2 different sources, the first one (VCC1) is +5V and it comes from the Arduino boards, and the 2nd one (VCC2) is +12V which is the same as motor nominal voltage.

Arduino remote controlled DC motor code:
The code below doesn’t use any library for the remote control, it is based on hardware interrupt-on-change on the Arduino uno pin 2.
The message of the NEC protocol is 32-bit long, the code is similar to the one which I used in the decoding project except that I added repeat code detection for buttons 2 (0x40BFB04F) and 3 (0x40BF708F).

I used Timer1 module to measure pulses and spaces widths, it is configured so that is increments by 2 every 1 us (1/8 prescaler).

Finally, the video below shows a simple hardware circuit of the project:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.