Back to Parent

//Tejas kashyap #IOT
int tempPin = A3;
int LDR = 1;
int output = 8;
int output2 = 7;

double temp = 0.0;
double tempF = 0.0;

void setup()
{
  
  Particle.variable("temp", &temp, DOUBLE);
  Particle.variable("tempF", &tempF, DOUBLE);

  pinMode(tempPin, INPUT);
  pinMode(LDR, INPUT);
  pinMode(output, OUTPUT);
  pinMode(output2, OUTPUT);
}

void loop()
{
  
  int reading = analogRead(tempPin);

  double voltage = (reading * 3.3) / 4095.0;

  temp = (voltage - 0.5) * 100;

  tempF = ((temp * 9.0) / 5.0) + 32.0;
  Particle.publish("text",String(tempF));
            Particle.publish("text",String(LDR));

  if(LDR == 1)
     {  digitalWrite(output2,LOW);
         digitalWrite(output,LOW);
       }
  
 else if(LDR != 1)
     {  if(tempF>=65.0)
          { Particle.publish("text",String(tempF));
            Particle.publish("text",String(LDR));
            delay(1000);
            digitalWrite(output,HIGH);
            digitalWrite(output2,LOW);
            delay(3000); 
          }
     
      else if(tempF<65)
          { Particle.publish("text",String(tempF));
            Particle.publish("text",String(LDR));
              
              digitalWrite(output2,HIGH);
            digitalWrite(output,LOW); } 
     }   

}
Click to Expand

Content Rating

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

0