Last active
March 6, 2021 19:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*************Telecommande_et_LEDs ********************* | |
4 LEDs branchées aux sorties 2-5 de l'Arduino sont contrôlées | |
au moyen d'une télécommande recyclée suivant le protocole Panasonic. | |
Utilisation de la librairie IRremote de Ken Shirriff | |
(http://www.righto.com/). | |
Plus d'infos: | |
http://electroniqueamateur.blogspot.com/2013/08/controler-un-arduino-avec-une.html | |
********************************************************/ | |
#include <IRremote.h> | |
int IR_RECEIVE_PIN = 11; // récepteur IR à la broche 11 du Leonardo | |
int LED_state [4]; // 0 quand la LED est éteinte | |
void setup() | |
{ | |
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK); | |
Serial.begin(115200); | |
for (int i = 0; i <= 3; i++) { | |
pinMode(i + 2, OUTPUT); | |
} | |
} | |
void loop() { | |
if (IrReceiver.decode()) { | |
IrReceiver.resume(); | |
if (IrReceiver.decodedIRData.address == 0x8) { | |
switch (IrReceiver.decodedIRData.command) { | |
case 0x10: | |
Serial.println("Bouton 1"); | |
LED_state[0] = !(LED_state[0]); | |
break; | |
case 0x11: | |
Serial.println("Bouton 2"); | |
LED_state[1] = !(LED_state[1]); | |
break; | |
case 0x12: | |
Serial.println("Bouton 3"); | |
LED_state[2] = !(LED_state[2]); | |
break; | |
case 0x13: | |
Serial.println("Bouton 4"); | |
LED_state[3] = !(LED_state[3]); | |
break; | |
} | |
} | |
} | |
for (int i = 0; i <= 3; i++) { | |
digitalWrite(i + 2, LED_state[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment