Project IOT
Project IOT
// Start code
// val = analogRead(tempPin);
// int mv = ( val/1023.0)*5000;
// int cel = mv/10;
// End code
//new code
float temperature = (5.0*analogRead(tempPin)*100.0/1024.0) /10;
// end code
LCD.setCursor(10, 0); //Set the cursor to the tenth column of the first row
LCD.print(" "); //Print blanks to clear the row
LCD.setCursor(10, 0); //Set Cursor again to the tenth column of the first row
LCD.print((int) (targetDistance + 0.5)); //Print measured distance
LCD.print("cm "); //Print your units
LCD.setCursor(0, 1); //Set the cursor to the first column of the second row
LCD.print(" "); //Print blanks to clear the row
LCD.setCursor(0, 1); //Set Cursor again to the first column of the second row
if (targetDistance > 40) {
LCD.print("LEV LOW ");
//LCD.print(sensors.getTempCByIndex(0));
LCD.print(temperature);
LCD.print((char)223);
LCD.print ("C");
}
else if (targetDistance < 40 && targetDistance > 20) {
LCD.print("LEV MED ");
//LCD.print(sensors.getTempCByIndex(0));
LCD.print(temperature);
LCD.print((char)223);
LCD.print ("C");
}
else (targetDistance < 20); {
LCD.print ("LEV HIGH ");
//LCD.print(sensors.getTempCByIndex(0));
LCD.print(temperature);
LCD.print((char)223);
LCD.print ("C");
}
delay(2000);
if (targetDistance > 40) {
digitalWrite (13, HIGH); //Green LED ON
}
else {
digitalWrite(13, LOW); //Green LED OFF
}
if (targetDistance < 40 && targetDistance > 20) {
digitalWrite (8, HIGH); //Yellow LED ON
}
else {
digitalWrite(8, LOW); //Yellow LED OFF
}
if (targetDistance < 20) {
digitalWrite(10, HIGH); //Red LED ON
delay(2000);
digitalWrite(10, LOW); //Red LED OFF
}
else {
digitalWrite(10, LOW); //Red LED OFF
}
}