Created
February 4, 2017 14:31
-
-
Save gausie/01578ebbe466396ad6a4da77bbf12205 to your computer and use it in GitHub Desktop.
Script to on/off my Toshiba TV when I open/close the cupboard its in!
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
| #include <IRremote.h> | |
| IRsend irsend; | |
| int avoidSensor = 2; | |
| int lastAvoidState = 1; // 1 means clear, 0 means covered | |
| void setup() | |
| { | |
| Serial.begin(9600); | |
| pinMode(avoidSensor, INPUT); | |
| } | |
| void sendOnOffSignal() { | |
| for (int i = 0; i < 3; i++) { | |
| irsend.sendRC5(0x84C, 12); | |
| delay(40); | |
| } | |
| } | |
| void loop() { | |
| int avoidState = digitalRead(avoidSensor); | |
| if (avoidState != lastAvoidState) { | |
| lastAvoidState = avoidState; | |
| sendOnOffSignal(); | |
| } | |
| delay(1); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Using a
Keyes IR Transmitterand aKeyes Avoid Detectorfrom a cheap box of knock-off sensors and transmitters I bought a few years ago.