Arduino Tutorial 64: Understanding and Using the Infrared (IR) Remote to Control a Project

preview_player
Показать описание
You guys can help me out over at Patreon, and that will help me keep my gear updated, and help me keep this quality content coming:

In this tutorial we show you had to add an Infrared (IR) remote to your arduino project. This lesson gets you stated, and then we will add features in the next lesson.

You can get the kit I am using for this series at the following link:

I strongly suggest picking up an arduino nano, since it can plug directly into the breadboard, making a portable system more practical. You can pick one up here:

As projects get more complicated in these lessons, you guys really need to get a set of breadboard jumper wires which allow you to make neater connections on the board in your projects. You can pick a pack of these wires up here:

In addition as projects get more complicated, you are going to need a bigger breadboard. This is a reasonable one here:

You can find more resources on our WEB site:

#Arduino
Рекомендации по теме
Комментарии
Автор

I did my homework and I have come all the way through lesson number one; Paul, your lessons are pretty darling. Long live Paul!.... fan from Ethiopia

kirubeltekle
Автор

Only a few number of people are watching your videos :(
Remember one thing grandpa, u are sharing a lot of knowledge to us, and we are very grateful :)

nithinsai
Автор

Thank you for not editing out your mistakes. I learn a lot by just watching them pop up and you figuring out what they are and correcting them.

rondeacon
Автор

For everyone who got a strange error regarding a "deprecated" function, try switching the IR library to an earlier version (for example, 2.8.0)!
Great video by the way Paul!

JustinS
Автор

Paul -- I am so grateful to you for making all these great lessons. The IR sensor is really fun. I listen to every single one of your videos all the way through. You are LEGEND!! P.S. Agree that gas station coffee is not as good as homemade. For students - the library has been changed since this video was made. You have to download the older library that Paul uses.

laurakav
Автор

I was getting for every reading. Checked my very short, very simple code 1000 times and even burned up my IR receiver by wiring it backwards while troubleshooting. I finally discovered that the IRRemote library version I was using (4.1.2) has a problem. I reverted back to IRRemote v3.5.2, stole an IR receiver from an old heater, and I'm back in business!

eancarris
Автор

Man, this was a journey, but I AM LEGEND! Using the very latest library. Was up til 3am last night and couldn't get any meaningful prints. At a complete loss today, I removed everything from the breadboard, put it all back, and rewired it. Like nothing was ever wrong, it worked! Stole code from various sources since I couldn't find a very concise official documentation... Probably didn't look hard enough.... But after tinkering for a while, seeing what was really needed, and what wasn't, I have a code structure that looks exactly like Teach's, but uses updated commands and gets rid of unnecessary and deprecated lines.

Although Teach probably doesn't like us giving away answers, due to the number of folks who have, with recent library versions, had loads of trouble, below is the very simplest version I could make work as expected. There have been a few versions posted in these comments (big thank you to you folks!). Only giving away what's needed to set up the receiver and get a serial mon print. IRRemote library version 3.7.1 (July 2022).

NOTE: Oddly, I am only able to read 2 digit hex values from this remote and receiver combo... If anyone can explain that, I would love to know! The code below works for me, though!

#include <IRremote.h>
int IRpin = 9;
int cmd;
int dt=250;

void setup() {
Serial.begin(9600);
IrReceiver.begin(IRpin);
}

void loop() {

while (! IrReceiver.decode()) {
}


Serial.println("HEX: " + String(cmd, HEX));
delay(dt);
IrReceiver.resume();

OTHER NOTE:
I tried using to store in our "cmd" variable, but every remote button would read the same value. It was a lot longer than the 2 digits I was getting, though which was almost interesting...

pointer
Автор

This lesson almost had me giving up on learning to program Arduinos. I uploaded the program and every time I pressed the remote button it gave me a different number...completely different and never repeated. Also, it was a 7 digit number instead of a 5 digit like you got. Then I read about the library version issue. I converted from 2.X to 3.X, thanks to someone's excellent comment below. Same exact result. Then I went back to version 2.8.1 as someone else suggested. Same exact result. Then I went back to 2.2.3 like you used. Same exact result. I checked, rechecked, re-recheck, re-re-rechecked and re-re-re-re-re-rechecked my code. It was exactly the same as yours. Hours trying to research on the internet did not help. Finally, it just happened that a new IR sensor just came in the mail. I had ordered it for a project I'm going to build once I learn Arduino programming a little better. Out of curiosity, I plugged the new one into my circuit and BOOM! it started working perfectly. Each button on the remote is now giving a single, discrete 5-digit number. I can only assume the Elegoo IR sensor was not working properly. Now I need to work on regrowing all the hair I pulled out trying to figure this out.

picklefish
Автор

I am legend. I was able to finish this homework. Also, the IRreceiver library has been updated since you did this lesson, and the code you provided threw an error message saying that the code might give unreliable results. I was able to track down the changes and modify the code as required, and got it working without asking others for assistance. Thank you Paul for your lessons and your encouragement. In the past when I have tried to learn programming I would have given up long before this. You are also a legend! Thank you

davidbuckley
Автор

I have a fix for those of you getting nothing but zeros!! It's the library!
I pulled my hair out for hours, then went back to where Paul downloaded his OLDER version (2.2.3). I deleted the newer version, installed 2.2.3 and everything worked properly!!

libbytardalo
Автор

I am legend, not bad for a 69 year old. Too cold in N.Z for iced coffee, as below zero here, red wine works.
Great series Paul.

phillovegrove
Автор

I am legend. One of the things that this lesson taught me was the value of looking at the community comments and support below. I too couldn't get the library that the tutorial uses 2.2.3 to work with the commands, as Paul had given them, but you guys helped, and I was able to use the latest IRremote library 3.6.1. and the code changes suggested by you out there in the community kind enough to share. You guys are so cool - all help greatly appreciated Thank you. I'm sure Paul would appreciate the support network being so robust too.
Fun to play with the remote control.

richardalexander
Автор

I don't even watch any other arduino videos anymore. The risk/reward benefit just doesn't compare to this man's consistency.

marcomoriarty
Автор

Paul, I posted a review on Amazon regarding the Arduino mega 2560 and in the comments I mentioned your lessons, hopefully this will get more subscribers.

stephenmarshall
Автор

LEGEND ! oooh loving this one. mapped it out a treat. Cut & paste from the serial monitor was a handy method ... I noticed my spare TV controllers created a HEX signal too. Very interesting. Most excellent video as always. Thank you.

doverivermedia
Автор

The amount of knowledge you’ve been sharing with us is impeccable!

hertzmaddentv
Автор

Happy Holidays Paul! Another great lesson to pass on to my students. This is a great tutorial because it deals with a real life application, our television remote control. Students tend to show greater interest in lessons that explain real life technology they interact with every day. Also, adding a remote to your project takes things to an entirely new level. Thanks again and Marry Christmas. I have found that electronics is a nice shelter from the craziness of the world. I may not be able to solve the world's problems but I can solve my project problems!

hughpatterson
Автор

I am legend. This is the first time I've been able to actually do all the homework before the next session. Life is good.

rcsatx
Автор

you are real change maker to the world, look how old are you but despite your age look what you do, great job uncle

niceguy
Автор

We are still watching. Lovely videos, thank you, Paul. Newbies will appreciate your detailed method of tutoring more after watching other videos that don't explain anything as neat as you do

artursrikmanis
welcome to shbcf.ru