hello_mbot_infrared
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
hello_mbot_infrared [2025/02/03 15:17] – angelegt torsten.roehl | hello_mbot_infrared [2025/02/27 08:36] (aktuell) – [Code extrahieren] torsten.roehl | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== Hello mBot LineSensor | + | ====== Hello mBot Infrared |
+ | //Dieses **Arduino-Programm** empfängt Infrarotsignale (**IR**) vom mBot Infrarot-Empfänger und gibt den erkannten Tastencode und Button-Namen über die serielle Schnittstelle aus. Es verarbeitet Signale von einer IR-Fernbedienung, | ||
+ | {{ : | ||
+ | Die Makeblock IR-Fernbedienung. | ||
+ | |||
+ | ===== Quellcode (engl. Sourcecode) ===== | ||
<Code c linenums:1 | Listing 1: | <Code c linenums:1 | Listing 1: | ||
+ | #include < | ||
+ | MeIR ir; | ||
+ | |||
+ | void setup() { | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | if (ir.decode()) { | ||
+ | uint32_t value = ir.value; | ||
+ | Serial.print(" | ||
+ | Serial.println(value); | ||
+ | value = value >> 16 & 0xff; | ||
+ | Serial.print(" | ||
+ | Serial.println(value); | ||
+ | Serial.print(" | ||
+ | switch(value) { | ||
+ | case IR_BUTTON_A: | ||
+ | case IR_BUTTON_B: | ||
+ | case IR_BUTTON_C: | ||
+ | case IR_BUTTON_D: | ||
+ | case IR_BUTTON_E: | ||
+ | case IR_BUTTON_F: | ||
+ | case IR_BUTTON_SETTING : Serial.println(" | ||
+ | case IR_BUTTON_LEFT: | ||
+ | case IR_BUTTON_RIGHT: | ||
+ | case IR_BUTTON_UP: | ||
+ | case IR_BUTTON_DOWN: | ||
+ | case IR_BUTTON_0: | ||
+ | case IR_BUTTON_1: | ||
+ | case IR_BUTTON_2: | ||
+ | case IR_BUTTON_3: | ||
+ | case IR_BUTTON_4: | ||
+ | case IR_BUTTON_5: | ||
+ | case IR_BUTTON_6: | ||
+ | case IR_BUTTON_7: | ||
+ | case IR_BUTTON_8: | ||
+ | case IR_BUTTON_9: | ||
+ | default: | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | } | ||
</ | </ | ||
+ | |||
+ | ==== Code extrahieren ==== | ||
+ | |||
+ | Der folgende Code-Snippet extrahiert den // | ||
+ | <Code c linenums:1 | Listing 1: | ||
+ | uint32_t | ||
+ | | ||
+ | value = value >> 16 & 0xff; | ||
+ | | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Die Funktion extrahiert das 3. Byte eines 32-Bit-Werts ('' | ||
+ | |||
+ | |||
hello_mbot_infrared.1738595853.txt.gz · Zuletzt geändert: 2025/02/03 15:17 von torsten.roehl