Skip to content

Instantly share code, notes, and snippets.

@krvarma
Created January 31, 2015 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krvarma/e8235d18a318662a63c5 to your computer and use it in GitHub Desktop.
Save krvarma/e8235d18a318662a63c5 to your computer and use it in GitHub Desktop.
Spark Core IFTTT and LDR Sample
#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