//This code is designed for the Minion connection tool
//This code is for the parent side of the device
//When the hand of a minion is pressed a picture is taken
//by the activation of a servo motor that presses the capacitive touch
//button on an iPhone camera that is already in camera mode
//Once this picture is taken, it sends it to the cloud using
//IFTTT protocol which syncs it dropbox, when this happens
//a signal is sent to the other matching Minion, so it's light turns on
//when the child acknowledges
//push buttons
int takephotobutton = D0;
int photoseenbutton = D1;
//LED
int ledPin = D2;
//counter that keeps track of photos parent has taken since child last checked
int photocounterP=0;
void setup() {
Spark.variable("photocount", &photocounterP, INT);
// sets pin as input
pinMode(takephotobutton, INPUT_PULLUP);
// sets pin as input
pinMode(photoseenbutton, INPUT_PULLUP);
// sets pin as output
pinMode(ledPin, OUTPUT );
//Subscribe to child core's photo activation feed
Spark.subscribe("AASY/Child", handlePhotos);
//Subscribe to child's feed for having viewed parent's photos
//Spark.subscribe("AASY/ChildView", countReset);
}
void loop() {
//check to see if takephotobutton is pressed
//takephotobutton is wired so that it will output LOW when pressed down
int takephoto = digitalRead(takephotobutton);
//update photo count
if(takephoto == LOW){
photocounterP = photocounterP + 1;
}
//if photocount is greater than one send to the cloud that photos available
if(photocounterP >0){
Spark.publish("AASY/Parent", "PHOTO", 60, PUBLIC);
}
//check to see if photoseenbutton is pressed
//photoseenbutton is wired so that it will output LOW when pressed down
int photoseen = digitalRead(photoseenbutton);
//if photo has been seen then let child core know
if(photoseen == LOW) {
Spark.publish("AASY/Parent", "VIEW", 60, PUBLIC);
digitalWrite(ledPin, LOW);
}else{
//Spark.publish("AASY/ParentView", "NO", 60, PUBLIC);
}
delay(10000);
}
void handlePhotos( const char *event, const char *data) {
if(strcmp(data, "PHOTO")==0) {
digitalWrite(ledPin, HIGH);
}
if(strcmp(data, "VIEW")==0) {
photocounterP = 0;
}
}
/*
//handler function that turns other device's LED on when this device takes
//a photo
void ledToggle(const char *event, const char *photowaiting) {
if(strcmp(photowaiting, "YES")==0) {
digitalWrite(ledPin, HIGH);
}
}
//handler function to reset photo counter on paired device when photoseen
//button has been pressed
void countReset(const char *event2, const char *photoseen){
if(strcmp(photoseen, "YES")==0){
photocounterP = 0;
}else{
//tester code to see if the this countReset is running at all
//photocounterP= photocounterP + 1;
}
}
*/
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .