The Elegoo Kit contains a simple IR module and remote which allow you to add remote control to your arduino project. In this lesson we show you how to connect the remote, and then how to send signals to the arduino using the remote unit. This video takes you through the process step by step.
The code below will get you started, and then you can expand the code to map all the buttons to simple string commands.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #include <IRremote.h> //Make sure to install the library int IRpin=9; IRrecv IR(IRpin); decode_results cmd; String myCom; void setup() { Serial.begin(9600); IR.enableIRIn(); } void loop() { while (IR.decode(&cmd)==0){ } Serial.println(cmd.value,HEX); delay(1500); IR.resume(); if (cmd.value==0xFF6897){ myCom="zero"; Serial.println(myCom); } if (cmd.value==0xFFA25D){ myCom="pwr"; Serial.println(myCom); } } |
We are building this with parts from our Elegoo Kit , and our actual build is using an Arduino Nano, which allows the project to be built on a single breadboard. You can get the neat jumper wires HERE.