In this lesson we show how to use the IR remote in the Elegoo Smart Car to send signals to the robot. The IR remote sends IR signals to the IR detector on the Electronic Shield sitting on top of the Smart Car. In this lesson we show how to install the IR library, and how to write code to send and detect IR signals. The code we develop in today’s lesson is included below for your convenience.
Arduino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <IRremote.h>
intIRpin=12;
IRrecvIR(IRpin);
decode_resultscmd;
voidsetup(){
// put your setup code here, to run once:
Serial.begin(9600);
IR.enableIRIn();
IR.blink13(true);
}
voidloop(){
// put your main code here, to run repeatedly:
while(IR.decode(&cmd)==0){
}
Serial.println(cmd.value,HEX);
delay(500);
IR.resume();
}
Making The World a Better Place One High Tech Project at a Time. Enjoy!
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok