else if (command == "eight") tv.eight();
-
else if (command == "nine") tv.nine();
40
else if (command == "up") tv.up();
-
else if (command == "left") tv.left();
-
else if (command == "right") tv.right();
-
else if (command == "down") tv.down();
-
else if (command == "ret") tv.ret();
45
else if (command == "exit") tv.exit();
-
else if (command == "a") tv.a();
-
else if (command == "b") tv.b();
-
else if (command == "c") tv.c();
-
else if (command == "d") tv.d();
50
else if (command == "txt") tv.txt();
-
else if (command == "pip") tv.pip();
-
else if (command == "pre_ch") tv.pre_ch();
-
else if (command == "search") tv.search();
-
else if (command == "vol_up") tv.vol_up();
55
else if (command == "vol_down") tv.vol_down();
-
else if (command == "dual") tv.dual();
-
else if (command == "usb_hub") tv.usb_hub();
-
else if (command == "mute") tv.mute();
-
else if (command == "p_size") tv.p_size();
60
else if (command == "ch_list") tv.ch_list();
-
else if (command == "subtitle") tv.subtitle();
-
else if (command == "prog_up") tv.prog_up();
-
else if (command == "prog_down") tv.prog_down();
-
else if (command == "pause") tv.pause();
65
else if (command == "rewind") tv.rewind();
-
else if (command == "forward") tv.forward();
-
else if (command == "menu") tv.menu();
-
else if (command == "smart_tv") tv.smart_tv();
-
else if (command == "record") tv.record();
70
else if (command == "play") tv.play();
-
else if (command == "stop") tv.stop();
-
else Serial.println("Command is unknown.");
-
-
command = "";
75
input_available = false;
-
}
-
}
-
In lines 3 to 5, we define a global
TvRemote
object named
tv
, a string named
command
that holds the current command, and a Boolean flag named
input_available
that is true when the sketch has received a new command. As
usual, we initialize the serial port in the
setup
function.
The Arduino calls the
serialEvent
function defined in line 11 when new data
arrives at the serial port. (Learn more about
serialEvent
in Serial Communication
Using Various Languages, on page 255.) We append that data to the
command
report erratum • discuss
Cloning a Remote • 211
www.it-ebooks.info