]> git.piffa.net Git - sketchbook_andrea_bak/blob - hardware/Infrared_controller/IR_reading_mapped/IR_reading_mapped.ino
Initial Commit
[sketchbook_andrea_bak] / hardware / Infrared_controller / IR_reading_mapped / IR_reading_mapped.ino
1 // Remote infrared control
2 // http://www.instructables.com/id/Arduino-Infrared-Remote-tutorial/
3
4 // Requires library: https://github.com/shirriff/Arduino-IRremote
5 // Numbers 1->6 mapped with a switch construct
6 // 
7 // Warning: DO NOT coonect the IR sensor to the Arduino without
8 // the PCB module
9
10 #include <IRremote.h>
11 #include <IRremoteInt.h>
12
13 int RECV_PIN = 11;
14 IRrecv irrecv(RECV_PIN);
15 decode_results results;
16
17 void setup()
18 {
19   Serial.begin(9600);
20   irrecv.enableIRIn(); // Start the receiver
21 }
22
23 void loop()
24 {
25   if (irrecv.decode(&results))
26   {
27     switch (results.value) {
28     case 0xFF30CF:
29       Serial.println("Uno");
30       break;
31     case 0xFF18E7:
32       Serial.println("Due");
33       break;    
34     case 0xFF7A85:
35       Serial.println("Tre");
36       break;   
37     case 0xFF10EF:
38       Serial.println("Quattro");
39       break;   
40     case 0xFF38C7:
41       Serial.println("Cinque");
42       break;   
43     case 0xFF5AA5:
44       Serial.println("Sei");
45       break;   
46     case 0xFFFFFFFF:
47       Serial.println("Repeat");
48     }  
49     //Serial.println(results.value, HEX); // Debug: show value
50     irrecv.resume(); // Receive the next value
51
52   }
53 }
54
55
56
57
58