int sensorPin = A0;
int sensorVal = 0;
int baselineTemp = 18;
int number = 5;
int LedPin [5] = {D0, D1, D2, D3, D4};
void setup(){
Serial.begin(9600);
for (int x=2; x<5; x++){
pinMode(x, OUTPUT);
digitalWrite(x, LOW);
}
}
void loop()
{
sensorVal = analogRead(sensorPin);
Serial.print (sensorVal);
Serial.print ("ADC");
double Voltage = (sensorVal/4096.0)*3.3;
Serial.print (Voltage);
Serial.print ("Volts,");
double temperature = (Voltage - .5)*100;
Serial.print (temperature);
Serial.print ("degrees C");
Serial.println();
if (temperature < baselineTemp){
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}
else if (temperature >= baselineTemp+2 && temperature < baselineTemp+4){
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}
else if (temperature >= baselineTemp+4 && temperature < baselineTemp+6){
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
}
else if (temperature >= baselineTemp+6){
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
Particle.publish("temperature","Yo");
}
delay(1000);
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .