Back to Parent

void setup()
{
  /*Subscribe to a set of events published when an IFTTT widget is triggered by 
  a tweeting. The first one is connected to the account of a teammate for demo 
  purposes, the second one is connected to donaldTrump's twitter acound and the 
  last one is independent of a username so any other account can be used.*/
  Particle.subscribe("ChenMutiatLama/2019/Group4/LamaAlFulaij", action );
  Particle.subscribe("ChenMutiatLama/2019/Group4/realDonaldTrump", action );
  Particle.subscribe("ChenMutiatLama/2019/Group4/tweet", action );
  Particle.variable ("Motion",motion);
  
  //PIR is readable
  pinMode (PIRpin, INPUT_PULLDOWN);
 
  //Initialize all pixels to 'off'
  strip.begin();
  strip.show();
   
}

// Our event handler requires two bits of information
// This gives us:
// A character array that consists of the event name
// A character array that contains the data published in the event 
// we're responding to.
void action(const char *event, const char *data){
    //Particle.publish("acting");
    String m = strstr(data, "mexic" );
    String mCaps = strstr(data, "Mexic" );
    String r = strstr(data, "russia" );
    String rCaps = strstr(data, "Russia" );
    String s = strstr(data, "syria" );
    String sCaps = strstr(data, "Syria" );
    String i = strstr(data, "israel" );
    String iCaps = strstr(data, "Israel" );
    String v = strstr(data, "venezuela" );
    String vCaps = strstr(data, "Venezuela" );
    String c = strstr(data, "chin" );
    String cCaps = strstr(data, "Chin" );
    String country = "no";
    if(m!=NULL|| mCaps!=NULL){
        mexicanFlag();
     
    }
    else if(r!=NULL|| rCaps!=NULL){
        russianFlag();
    }
    else if(s!=NULL|| sCaps!=NULL){
        syrianFlag();
    }
    else if(i!=NULL|| iCaps!=NULL){
        israeliFlag();
    }
    else if(v!=NULL|| vCaps!=NULL){
        venezuelanFlag();
    }
    else if(c!=NULL|| cCaps!=NULL){
        chineseFlag();
    }
    else{
        rainbow();
    }
    //check for a reaction
    checkReaction(data);
    turnoff();
    
}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0