![Keywish ATMEGA328P-PU Instruction Manual Download Page 48](http://html.mh-extra.com/html/keywish/atmega328p-pu/atmega328p-pu_instruction-manual_1962647048.webp)
48
in Figure 4-5-1 is removed. Then open the "serial monitor" and use the remote control to align the receiving
head and press any button to observe the value displayed in the "serial monitor" and record it for later
development and use, as shown in Figure 4-5-4.
Picture 4-5-4 Remote coded query
n Figure 4-5-
4, we can see the values of Ir Code “0x45” and keyname
“1”, where “0x45” is the code of
a button on the remote control and “1” is the name of the button function of the remote control. The total
encoding value of the supporting remote control is shown in Figure 4-5-4.
#include "IRremote.h"
IRremote ir
(
12
);
unsigned
char
keycode
;
char
str
[
128
];
void
setup
()
{
Serial
.
begin
(
9600
);
ir
.
begin
();
}
void
loop
()
{
if
(
keycode
=
ir
.
getCode
())
{
String key_name
=
ir
.
getKeyMap
(
keycode
);
sprintf
(
str
,
"Get ir code: 0x%x key name: %s \n"
,
keycode
,
(
char
*)
key_name
.
c_str
());
Serial
.
println
(
str
);
}
else
{
// Serial.println("no key");
}
delay
(
110
);
}