Created
July 8, 2013 06:27
-
-
Save basilleaf/5946621 to your computer and use it in GitHub Desktop.
read of photocell light sensor triggers IR LED to emulate press of the #8 key on a Sony remote - to open Teleclaw at sunrise.
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
#include "IRremote.h" | |
IRsend irsend; | |
int LDR_threshold = 250; // this number or higher = sunshine, calibrate me! | |
int LDR_Pin = A0; // analog pin 0 | |
int claw_state = 0; // claw is assumed initially closed for now.. | |
void setup() | |
{ | |
Serial.begin(9600); | |
} | |
void loop() { | |
int LDRReading = analogRead(LDR_Pin); | |
Serial.println(LDRReading); | |
if (claw_state == 0 && LDRReading > LDR_threshold) { | |
// the sun is up, open the claw! | |
openClaw(); | |
claw_state = 1; | |
} | |
delay(1000*60*5); // check every 10 minutes | |
} | |
void openClaw() { | |
Serial.println("opening claw"); | |
// emit the signal to open claw > 1 times, saw some misses | |
for (int i = 0; i < 2; i++) { // do it 4 times because sometimes it misses | |
delay(1000); | |
// this loop of 3 with 100 delay is part of the Sony spec afaict | |
for (int i = 0; i < 3; i++) { | |
irsend.sendSony(0xE13A5, 20); // Sony TV 8 key code | |
delay(100); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment