Habib-12209
Lab # 3
Code 1:
float temp;
int reading;
int temppin = 0;
void setup() {
analogReference(INTERNAL);
Serial.begin(9600);
void loop (){
reading = analogRead(temppin);
temp = (reading *5.0/1023) * 100.0;
Serial.print("temperature = ");
Serial.println(temp);
delay(1000);
Code 2:
#include <LiquidCrystal.h>
const int temperaturePin = A0, rs = 12, en = 11, d4 = 5, d5 = 4, d6
= 3, d7 = 2;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7);
void setup() {
Serial.begin(9600);
void loop() {
int sensorValue = analogRead(temperaturePin);
float temperatureC = (sensorValue*5.0/1023) * 100.0;
lcd.begin(16,2);
lcd.print("Temp: ");
lcd.print(temperatureC);
lcd.setCursor(0, 1);
lcd.print("Status: ");
// Determine the status message based on the temperature range
String status;
if (temperatureC >= 0 && temperatureC <= 100) {
status = "Cold";
} else if (temperatureC >= 150 && temperatureC <= 200) {
status = "Fair";
} else {
status = "Warm";
lcd.setCursor(8, 1);
lcd.print(status);
delay(1000);