Back to Parent

// This #include statement was automatically added by the Particle IDE.
#include "lib1.h"


int led1 = D0; 
int counter1 = 0;

int led2 = D4;
int counter2 = 0;

int led3 = D6;
int counter3 = 0;

void setup() {


  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  
//things the tree responds to on the twitter feed
  
  Particle.subscribe( "Compost height increased" , handleSharedEvent);
  Particle.subscribe( "Plant watered" , handleSharedEvent);
  
  delay(10000);

}

//event to retrieve information from twitter account

void handleSharedEvent(const char *event, const char *data)
{
  Serial.println("wow");
  String deviceID = System.deviceID();
  String eventName = String(event);
  if (eventName.indexOf(deviceID) != -1) {
    return;
  }
  if( data == "1"): counter1++;
  if( data == "2"): counter2++;
  if( data == "3"): counter3++;
  
  digitalWrite(led1, counter1);
  delay(300);
  digitalWrite(led2, counter2);
  delay(300);
  digitalWrite(led3, counter3);

  delay(1000);

  digitalWrite(led1, counter1);
  delay(300);
  digitalWrite(led2, counter2);
  delay(300);
  digitalWrite(led3, counter3);
  
}

//

// void loop(){
//     digitalWrite(led1, HIGH);
//     analogWrite( LED_1, 255);
//     delay(1000);
    
//     digitalWrite(led1, LOW);
//     analogWrite( LED_1, 0);
//     delay(1000);
    
    
// }
Click to Expand

Content Rating

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

0