Created
July 25, 2016 08:19
-
-
Save xseignard/c8791b43670f0bf1832d38b2feac91fc to your computer and use it in GitHub Desktop.
This file contains 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
// cf. http://www.righto.com/2010/03/detecting-ir-beam-break-with-arduino-ir.html | |
// 2 ir leds on PIN 3, in parallel | |
#include <IRremote.h> | |
#define PIN_IR 3 | |
#define PIN_RED 4 | |
#define PIN_BLUE 5 | |
#define PIN_STATUS 9 | |
IRsend irsend; | |
void setup() { | |
Serial.begin(9600); | |
pinMode(PIN_RED, INPUT); | |
pinMode(PIN_BLUE, INPUT); | |
pinMode(PIN_STATUS, OUTPUT); | |
irsend.enableIROut(38); | |
irsend.mark(0); | |
delay(1000); | |
} | |
void loop(){ | |
// but rouge | |
if (digitalRead(PIN_RED)) { | |
// faire qqch | |
digitalWrite(PIN_STATUS, HIGH); | |
delay(500); | |
} | |
// but bleu | |
else if (digitalRead(PIN_BLUE)) { | |
// faire qqch | |
digitalWrite(PIN_STATUS, HIGH); | |
delay(500); | |
} | |
// rien | |
else { | |
digitalWrite(PIN_STATUS, LOW); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment