Hallo,
Ich beschäftige mich gerade damit, meine Stereoanlage automatisiert
einschalten zu lassen sobald der TV gestartet wird. Das ganze plane ich
mit einem Arduino UNO zu verwirklichen.
Nun habe ich mit folgendem Sketch die IR-Codes der Fernbedienung
herausgefunden.
1 | #include <IRremote.h>
|
2 |
|
3 | int RECV_PIN = 11;
|
4 |
|
5 | IRrecv irrecv(RECV_PIN);
|
6 |
|
7 | decode_results results;
|
8 |
|
9 | void setup()
|
10 | {
|
11 | Serial.begin(9600);
|
12 | irrecv.enableIRIn(); // Start the receiver
|
13 | }
|
14 |
|
15 | // Dumps out the decode_results structure.
|
16 | // Call this after IRrecv::decode()
|
17 | // void * to work around compiler issue
|
18 | //void dump(void *v) {
|
19 | // decode_results *results = (decode_results *)v
|
20 | void dump(decode_results *results) {
|
21 | int count = results->rawlen;
|
22 | if (results->decode_type == UNKNOWN) {
|
23 | Serial.println("Could not decode message");
|
24 | }
|
25 | else {
|
26 | if (results->decode_type == NEC) {
|
27 | Serial.print("Decoded NEC: ");
|
28 | }
|
29 | else if (results->decode_type == SONY) {
|
30 | Serial.print("Decoded SONY: ");
|
31 | }
|
32 | else if (results->decode_type == RC5) {
|
33 | Serial.print("Decoded RC5: ");
|
34 | }
|
35 | else if (results->decode_type == RC6) {
|
36 | Serial.print("Decoded RC6: ");
|
37 | }
|
38 | Serial.print(results->value, HEX);
|
39 | Serial.print(" (");
|
40 | Serial.print(results->bits, DEC);
|
41 | Serial.println(" bits)");
|
42 | }
|
43 | Serial.print("Raw (");
|
44 | Serial.print(count, DEC);
|
45 | Serial.print("): ");
|
46 |
|
47 | for (int i = 0; i < count; i++) {
|
48 | if ((i % 2) == 1) {
|
49 | Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
|
50 | }
|
51 | else {
|
52 | Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
|
53 | }
|
54 | Serial.print(" ");
|
55 | }
|
56 | Serial.println("");
|
57 | }
|
58 |
|
59 |
|
60 | void loop() {
|
61 | if (irrecv.decode(&results)) {
|
62 | Serial.println(results.value, HEX);
|
63 | dump(&results);
|
64 | irrecv.resume(); // Receive the next value
|
65 | }
|
66 | }
|
Der besagte Sketch sagte mir das der Einschaltcode entweder
Aus/Ein
Protocol: RC5
Value: 50C (12 bits)
oder
Protocoll RC5
Value: DOC (12 bits)
ist. Komischerweise wechselt dies immer. Ich nehme an der erste Code ist
für das Starten der Stereo Anlage (Philipps MCM277) und der andere ist
zum Ausschalten.
Soweit so gut,wenn ich diese Codes in einen Sende Sketch einfüge.
1 | #include <IRremote.h>
|
2 |
|
3 | IRsend irsend;
|
4 |
|
5 |
|
6 | void setup()
|
7 | {
|
8 | Serial.begin(9600);
|
9 | }
|
10 |
|
11 | void loop() {
|
12 |
|
13 | irsend.sendNEC(0x50C, 11);
|
14 | delay(10000);
|
15 | irsend.sendNEC(0xD0C, 11);
|
16 | delay(1000);
|
17 |
|
18 |
|
19 |
|
20 | }
|
Geht gar nix, die Stereo-Anlage starten nicht. Die Diode ist garantiert
richtig gepolt, da sie unter einer Kamera leuchtet. (Nur wenn man diese
an die Versorgungsspannung hängt) Beim AUsgangspin kann man nichts
erkennen, aber ich schätze das die Kamera & das Auge? zu träge für 36kHZ
sind.
Dieses 0x vor dem IR-Code stand in einem Forum, ohne meldet er mir:
"Ungültiger Suffix »C« an Ganzzahlkonstante" lässt sich also nicht
kompilen.
Mit meiner Annahme das die Zahl am Schluss des IR-Send Befehls die
Pinnummer ist liege ich doch richtig oder?
Was läuft falsch?