-
Notifications
You must be signed in to change notification settings - Fork 0
/
Creating_Useful_Commands_65.cpp
126 lines (101 loc) · 2.99 KB
/
Creating_Useful_Commands_65.cpp
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include <IRremote.h> // need to import the library (from online).
int IRpin = 9;
IRrecv IR(IRpin); //need to create the object and where it's connected to.
decode_results cmd; // command from the library (not the Arduino), where it reads input from the module (the remote)
String myCom;
void setup()
{
Serial.begin(9600)
IR.enableIRIn(); // strange capitalization ...
}
void loop() { // "we sit and wait for data"
while (IR.decode(&cmd) == 0){ // the ampersand gets the value and sends it to cmd (which is a variable created above)
// while it is empty ("0"), it will just turn over in an empty loop.
}
// after someone presses a button:
//Serial.println(cmd.value, HEX); // we told it that the value returned would be cmd, in the form of a hexidecimal.
// we don't actually need this, so later in the lesson, he took it away.
delay(1500); // need to give it a delay so that it doesn't go to fast
IR.resume(); // this restarts the reading
//Serial.println(cmd.value, HEX); // to show you the hex that cmd produces, but you don't need this
if (cmd.value == 0xFF6897) { //or whatever hex value the remote produces ("0x" says that a hex is coming)
myCom = "zero";
Serial.println(myCom);
}
if (cmd.value == 0xFF30CF) {
myCom = "one";
Serial.println(myCom);
}
if (cmd.value == 0xFF18E7) {
myCom = "two";
Serial.println(myCom);
}
if (cmd.value == 0xFF7A85) {
myCom = "three";
Serial.println(myCom);
}
if (cmd.value == 0xFF10EF) {
myCom = "four";
Serial.println(myCom);
}
if (cmd.value == 0xFF38C7) {
myCom = "five";
Serial.println(myCom);
}
if (cmd.value == 0xFF5AA5) {
myCom = "six";
Serial.println(myCom);
}
if (cmd.value == 0xFF42BD) {
myCom = "seven";
Serial.println(myCom);
}
if (cmd.value == 0xFF4AB5) {
myCom = "eight";
Serial.println(myCom);
}
if (cmd.value == 0xFF52AD) {
myCom = "nine";
Serial.println(myCom);
}
if (cmd.value == 0xFF629D) {
myCom = "v+";
Serial.println(myCom);
}
if (cmd.value == 0xFFE21D) {
myCom = "fun";
Serial.println(myCom);
}
if (cmd.value == 0xFF22DD) {
myCom = "rew";
Serial.println(myCom);
}
if (cmd.value == 0xFF02FD) {
myCom = "play";
Serial.println(myCom);
}
if (cmd.value == 0xFFC23D) {
myCom = "ff";
Serial.println(myCom);
}
if (cmd.value == 0xFFE01F) {
myCom = "dn";
Serial.println(myCom);
}
if (cmd.value == 0xFFA857) {
myCom = "v-";
Serial.println(myCom);
}
if (cmd.value == 0xFF906F) {
myCom = "up";
Serial.println(myCom);
}
if (cmd.value == 0xFF9867) {
myCom = "eq";
Serial.println(myCom);
}
if (cmd.value == 0xFFB04F) {
myCom = "st";
Serial.println(myCom);
}
}