In this project I am going to add in IR Remote Control (Infrared Kit) to the previous 2 Wheels Robot Platform (link).

Hardware
The first step is to mount the IR Receiver Module to the platform. You can use your creativity to do this. For me, I mount it at the front side of the platform.

Connect the 3 pin from the IR Receiver Module to 5V (Red), GND (Black) and Digital Pin 2 (Green).

Closer view, there are total of 5 jumper wire connected to Arduino, 2 for the 7.2V battery input (+ve and –ve), and another 3 for IR Receiver Module (5V, GND, and Signal).

Now, we are done with the hardware, let's move on to the coding/programming of the robot.
IRremote Library
For the coding, we will be using the IRremote library to encode the IR signal from the remote. You can download the IRremote library from the product page (http://www.e-shore.com.my/homepage/eshop/infrared-kit), click on the Arduino Library to initiate the download.

Then follow this guide (http://www.e-shore.com.my/homepage/installation-guide/arduino-ide/175-arduino-ide-new-library-installation-guide-windows.html) to install the IRremote library to your Arduino IDE. After installing the library, open the IRremote example called IRrecvDemo.

This example code will basically wait for IR signal from remote, once it receive IR signal, it will encode the signal and send the signal to PC through UART on Arduino. Modify the code by changing the RECV_PIN to 2, because we are using Digital Pin 2 for the Signal from IR Receiver Module.

After that upload the code to the 2 Wheel Robot Platform. Open Hyper Terminal on your PC and connect Hyper Terminal to the corresponding COM Port for Arduino UNO. Use the default setting for the COM Port on Hyper Terminal.

Try to press any button on the IR Remote Control and the Hyper Terminal should receive HEX code representing each button on the Remote Control. Take note that if you press and hold a button, the Hyper Terminal will first received the HEX code for that button, and after the first Hex code, it will keep receiving "FFFFFFFF" code until you release that button (this behavior is different for different remote control). We will need to take care of that in the coding later.

Table of the HEX Code for all button on the Remote Control.

|
Button |
HEX Code |
Button |
HEX Code |
Button |
HEX Code |
|
POWER |
FD00FF |
VOL+ |
FD807F |
FUNC/STOP |
FD40BF |
|
PREVIOUS |
FD20DF |
PLAY/PAUSE |
FDA05F |
NEXT |
FD609F |
|
DOWN |
FD10EF |
VOL- |
FD906F |
UP |
FD50AF |
|
KEY 0 |
FD30CF |
EQ |
FDB04F |
ST/REPT |
FD708F |
|
KEY 1 |
FD08F7 |
KEY 2 |
FD8877 |
KEY 3 |
FD48B7 |
|
KEY 4 |
FD28D7 |
KEY 5 |
FDA857 |
KEY 6 |
FD6897 |
|
KEY 7 |
FD18E7 |
KEY 8 |
FD9867 |
KEY 9 |
FD58A7 |
Code
For the code, I will use the template code from 2 Wheels Robot Platform (http://www.e-shore.com.my/homepage/all-projects/134-2-wheels-robot-platform-setup.html) to start. The code is a bit long; you can also download the full IR Remote Control Mobile Robot Code from the end of this article. Make sure that IRremote library is installed to ensure the functionality of the code.
The button assignment for the robot control is as follows:

The code will basically wait for IR Code, compare the received code with the HEX Code for the buttons involve, and perform the action based on the pressed button. From the code, you will see that there is a short delay of 150ms at line 91 which is required to wait for the repeating IR signal if the button is being held. This delay also prevents the code to quickly jump to "no IR signal received" portion that will stop the motor, even if the button is being held.
In the coding, the function motor( left , right ) will be use to ease the control of the left and right wheel. There are 2 variable for the function (left and right), which represent the left wheel and right wheel. Positive value set the motor forward and negative value will set the motor reverse, and the speed will be determine by the absolute value of these variable. For example calling the function motor(100,-70) will set the left wheel forward with speed of 100 and right wheel reverse with the speed of 70.
The sample video of the demo for IR Remote Control Mobile Robot:
Hardware List
- 2 Wheels MiniQ Balancing Robot Chassis or 2 Wheels MiniQ Robot Chassis (comes with castor)
- Arduino UNO
- 2A Motor Driver Shield for Arduino
- Infrared Kit
- 7.4V 500mAH Lipo Rechargeable Battery
- PCB Stands, screws, nuts and also some components






Comments
am looking for something like this
well explained tutorial
sorry for my english
RSS feed for comments to this post