Engineers - Reinvent Your Career with Robotics in the Next 90 Days
Consult with Experts in our Career Advancement Program for the Experienced Engineer & Tech Professional. Gain clarity & community. Apply Now!

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest

Program Arduino IR Remote to Control a Mobile Robot

Disclosure: Some of the links below are affiliate links. This means that, at zero cost to you, I will earn an affiliate commission if you click through the link and finalize a purchase. Learn Robotics is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a way for websites to earn advertising revenues by advertising and linking to Amazon.com.

Liz Miller Learn Robotics

Attention: Engineer Looking for a New Career in Robotics

Liz here 👋, Engineer,  Robotics Expert & founder of this website.

If I offered to help you advance your 6-Figure+ Robotics, Automation, or AI Career with a $10,000 sign-on bonus in the next 90 days or less…

…without wasting time on unnecessary certifications…
…without studying another coding language or tactic…
…without needing to get another degree and wasting years…

…would you take me up on that offer?

LIMITED SPACE: I have 6 more client spots open this week!

Want a spot? Click the button to access my 12-min training below and then apply if it makes sense.

If you liked my article on Controlling an Arduino Mobile Robot using a Bluetooth Keyboard, then you’re in for a real treat! This week’s article will be focused on using an Infrared (IR) sensor to control the Arduino Robot using a TV remote.

Before we get started, let’s learn about Infrared signals and sensors, and how the robot will use them to make decisions.

All things Infrared

There are plenty of tutorials and articles out there on how IR Remote Signals work, but here’s a great overview (and short) video from Rick Osgood.

He forgot to mention robots in his video, but that’s what this tutorial is for!

Our Task

Determine what code is being sent to the IR receiver, then command the robot to move according to the signal.

Step 1 – Download and Add the IR Remote Library from Github

Rafi Khan was kind enough to write an IR Remote Library, which will simplify our development for this project. Go ahead and download a copy of his library, here.

Next, you’ll need to add the .ZIP library to Arduino using the Library Importer. Navigate to Sketch > Include Library > Add .ZIP Library and select the .ZIP folder you just downloaded.

Step 2 – Run the Test Remote Code

Part A. Open up the Example Program, IRrecvDemo.ino (File > Examples > IRremote > IRrecvDemo)

Part B. Connect the IR Sensor to Pin 11 on your Arduino (any available PWM pin is fine, just make sure you change the value of int RECV_PIN = 11; to the pin you have your sensor plugged into.)

Part C. Upload the code to your Arduino. Open up the Serial Monitor. Then press some buttons on your remote. You should see a different HEX value displayed in the serial monitor for each button you press. Here’s a visual of what it should look like. (Your HEX Values may be different). The row of F’s signifies that a different HEX code has been received.

Program Arduino IR Remote to Control a Mobile Robot
HEX values received from pressing buttons on my TV Remote

Step 3 – Map Each Button to a Control Function

We’re going to modify this IRrecvDemo code to receive and return the results.value as an unsigned long. This will make it slightly easier to compare readings rather than converting to HEX. Once we have a reading, we will then initiate the robot.go() or move command on the robot.

Can you move?

If you haven’t written the code to initiate your motors (i.e. you cannot move forward, back, left, right, or stop), then YOU MUST write that code first. If your robot uses an L298N motor controller, then feel free to use my Create Robot library. Install this library like we did for the IR Remote library and be sure to follow the README.md for wiring and programming instructions. Once you have your move code configured and working, proceed to the following steps.

The thought process. Make sure you read this paragraph!

Using either if-statements, we can check each results.value reading and then initiate the robot movement. For example, if the “Up Arrow” on my TV remote is pressed, I may want the robot to move forward. We’ll first obtain the remote value for Up Arrow, then we’ll call move forward to make the robot move in the forward direction. Then we’ll repeat this for every direction. Sound simple enough?

Step 3 – Test Out the Code

Go ahead and watch the recap video. Sometimes a picture (or video) is worth a thousand words.

From the video you’ll see that I like to print out a String that says what I’m going to do when the remote button is pressed. That way, I can test to see if the code works before putting in the motor control. If it works, it’s just a matter of writing the line of code that controls the direction of the motor. If not, I can troubleshoot to see what needs to happen.

While you don’t need to do it that way, it’s an easy way to test your program while tethered to your computer. No need to worry about the robot flying off the table!

IR Remote + Arduino Robot = Simple RC Control

As you can see, it’s not too difficult to use a TV remote to control your Arduino Robot. All you need is an IR Receiver, the IR Remote Library, and a little time to develop your movement code. Using if-statements and logic comparisons, we can click a button on our remote to command the robot in a direction.

While I provided the skeleton for using the IR remote to control the robot’s movement, I challenge you to use the other buttons to control speed, sensors, and modes. And if you do take me up on that challenge, PLEASE share your project with me on Facebook or Instagram (tag @learnrobotics)! I enjoy seeing what my readers are up to!

And that’s a wrap!

Thanks for checking out this week’s article! If you enjoyed this tutorial, and want to see more like it, please leave a comment below.

Liz Miller Learn Robotics

Attention: Engineer Looking for a New Career in Robotics

Liz here 👋, Engineer,  Robotics Expert & founder of this website.

If I offered to help you advance your 6-Figure+ Robotics, Automation, or AI Career with a $10,000 sign-on bonus in the next 90 days or less…

…without wasting time on unnecessary certifications…
…without studying another coding language or tactic…
…without needing to get another degree and wasting years…

…would you take me up on that offer?

LIMITED SPACE: I have 6 more client spots open this week!

Want a spot? Click the button to access my 12-min training below and then apply if it makes sense.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Did this content help you? 🤖
...say thanks and send us a coffee!

Experience Engineers & Tech Pro’s:

Gain personalized guidance and direct mentorship from Liz in her Robotics Mentorship Program.

This 12-week professional advancement program will help you soar to the next level in your engineering career. My clients earn $100k+ with a $10k+ sign on bonus.

You’ll uncover strategies they *don’t* teach you in engineering school to help you earn more and live a meaningful life, all while working in high-impact robotics, automation, and AI roles.

Are you next? Check out the 12-min training I put together and then apply if it makes sense.

WHAT IS LEARN ROBOTICS?

Learn Robotics helps self-starters, hobbyists, and tech professionals get started in the robotics industry. 

We leverage a simple formula to make it easy to gain highly marketable and high-value 6-figure robotics & automation skills. 

Learn Robotics was founded by Robotics Engineer, Liz Miller, and leverages the Robotics Success Equation, our unique methodology that helps people learn to build robots while enhancing their careers for the future.

liz's featured robotics PROJECT ON YOUTUBE

Learn Robotics Botly Favicon

MORE LEARN ROBOTICS ARTICLES

Apply to Work with Liz in her Robotics Mentorship Program for Tech Professionals

Liz Miller Learn Robotics