-
Notifications
You must be signed in to change notification settings - Fork 1
/
ArduinoCarolers.ino
107 lines (91 loc) · 2.44 KB
/
ArduinoCarolers.ino
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
#include "ArduinoCarolers.h"
#include "SongUtils.h"
#include "Foundation.h"
#include <IRremote.h>
#include <IRremoteInt.h>
int curDeviceNumber = -1;
int lastMsg=-1;
int RECV_PIN = 11; // define input pin on Arduino
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
//Serial.begin(9600);
curDeviceNumber = GetDeviceId();
//Serial.print( F("Device number is "));
//Serial.println(curDeviceNumber);
irrecv.enableIRIn(); // Start the receiver
pinMode(piezo, OUTPUT);
}
void loop()
{
if (irrecv.decode(&results))
{
//Serial.println(results.value, HEX);
if (lastMsg != results.value)
{
lastMsg = results.value;
ProcessIrReceived(lastMsg);
}
irrecv.resume(); // Receive the next value
/*
Serial.println(results.value, HEX);
int *msgParts = DecodeIRMessage(results.value);
if (MsgForDevice = -1)
{
//This Message is not a valid message from arduino device, check if it is from Remote
}
irrecv.resume(); // Receive the next value
//Check master
if(results.value < 10){
Serial.println("Received Device number:"+results.value);
Serial.println("Check master");
CheckMaster();
}
if (results.value == 0xA90) //if receive, Power button
{
Serial.println("Received Power button from Sony Remote, send device number");
SendDeviceNumber();
irrecv.enableIRIn(); // Start the receiver
}
if (results.value == 0x010)
{
Serial.println(F("Received No 1 from Sony Remote"));
}
if (results.value == 0x810)
{
Serial.println(F("Received No 2 from Sony Remote"));
}
if (results.value == 0x410)
{
Serial.println(F("Received No 3 from Sony Remote"));
}
if (results.value == 0xC10)
{
Serial.println(F("Received No 4 from Sony Remote"));
}
if (results.value == 0x610)
{
Serial.println(F("Received No 7 from Sony Remote. Start Playing"));
Serial.println(F("Jingle Bell Rocks"));
PlayJingleBells(curDeviceNumber);
}
if (results.value == 0xE10)
{
Serial.println(F("Received No 8 from Sony Remote"));
}
if (results.value == 0x110)
{
Serial.println(F("Received No 9 from Sony Remote"));
}
if (results.value == 0xCE9)
{
Serial.println(F("Received STOP from Sony Remote"));
}
if (results.value == 0x2CE9)
{
Serial.println(F("Received PLAY from Sony Remote"));
}
*/
}
}