ARDUINO UNO Project 03: Love-O-Meter

Ingredients :

1- LED – RED                            # 3

2- Tempererature Sensor          #1

3- Wire

4- Resistor   220Ω                     #3

 

BUILD THE CIRCUIT

ARDUINO UNO Project 03 Love O Meter

ARDUINO UNO Project 03 Love O Meter

ARDUINO UNO Project 03 Love O Meter

 

Code:
const int SensorPin=A0;
const float baselineTemp=24.0;

void setup() {
for (int pinNum=3; pinNum<=5;pinNum++ ){
pinMode(pinNum, OUTPUT);
}
Serial.begin(9600);
}

void loop() {
int SensorValue=analogRead(SensorPin);
float voltage=(SensorValue/1024.0)*5.0;
float temperature=(voltage-.5)*100;

if(temperature<baselineTemp+2){
for (int pinNum=3; pinNum<=5;pinNum++ ){
digitalWrite(pinNum,LOW);}
} else if(temperature>= baselineTemp+2 && temperature<= baselineTemp+4 ){
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
}else if(temperature> baselineTemp+4 && temperature<= baselineTemp+6 ){
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
}else if (temperature> baselineTemp+6 ){
for (int pinNum=3; pinNum<=5;pinNum++ ){
digitalWrite(pinNum,HIGH);}
}
Serial.print(“Base Line Temp: “);
Serial.print(baselineTemp);
Serial.print(” , Sensor Value: “);
Serial.print(SensorValue);
Serial.print(” , Volts: “);
Serial.print(voltage);
Serial.print(” , Temperature: “);
Serial.println(temperature);

delay(250);

}