Back to Parent

//connectedIntimacyDevice1
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_spinfan1", spinfan1);
}
void loop()
{
 sensorReading = digitalRead(tiltSensor);
 if(sensorReading == HIGH){
   celebration1();
 }
 else{
 digitalWrite(fan, LOW);
 }
}
void celebration1(){
  Particle.publish("DIoT17_spinfan2");
}
void spinfan1(const char *event, const char *data) 
{
  digitalWrite(fan, HIGH);
  delay(5000);
}
Click to Expand

Content Rating

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

0