Back to Parent

int fan = D1;    //Controls the fan
int tiltSensor = D0;
int sensorReading;
void setup()
{
  pinMode(fan, OUTPUT);    //Sets up the the fan control pin
  pinMode(tiltSensor, INPUT);
  Particle.subscribe("DIoT17_spinfan2", spinfan2);
}
void loop()
{
  sensorReading = digitalRead(tiltSensor);
  if(sensorReading == HIGH){
  celebration2();
  }
  else{
  digitalWrite(fan, LOW);
  }
}
void spinfan2( const char *event, const char *data){
   digitalWrite(fan, HIGH);
   delay(5000);
}
void celebration2(){
  Particle.publish("DIoT17_spinfan1");
}
Click to Expand

Content Rating

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

0