Created
January 31, 2015 15:21
-
-
Save krvarma/e8235d18a318662a63c5 to your computer and use it in GitHub Desktop.
Spark Core IFTTT and LDR Sample
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
#define APP_DELAY (15 * 60 * 1000) | |
#define MAX_LIGHT_VALUE 12 | |
#define LDR_PIN A7 | |
// Sensor reading | |
int reading = 0; | |
char szValue[MAX_LIGHT_VALUE]; | |
void setup(void){ | |
Serial.begin(9600); | |
pinMode(LDR_PIN, INPUT); | |
} | |
void loop(void) { | |
// Read and map sensor value | |
reading = map(analogRead(LDR_PIN), 0, 4095, 0, 100); | |
// Let's debug | |
Serial.print("Reading: "); | |
Serial.println(reading); | |
// Publish Sensor value | |
sprintf(szValue, "%d", reading); | |
Spark.publish("LDR-LIGHTLEVEL", szValue, 60, PRIVATE); | |
// Delay application | |
delay(APP_DELAY); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment