#include<SoftwareSerial.h>
const int Tempsensor = A0;//connect output pin of lm35 to A0 oin of arduino
int bluetoothTx = 10;//connect to tx of bluetooth to 10th pin
int bluetoothRx = 11;//connect to rx of bluetooth to 11th pin
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup(){
pinMode(Tempsensor, INPUT);
pinMode(3, OUTPUT);//blue pin of rgb led
pinMode(4, OUTPUT);//green pin of rgb led
pinMode(5, OUTPUT);//red pin of rgb led
Serial.begin(9600);//serial coummunication begin
bluetooth.begin(9600);//bluetooth communication begin
}
void loop(){
float temp = analogRead(Tempsensor);//read temperature sensor voltage
temp = temp * 0.48828125;//(5*1000)/1024 = 0.48828125 from sensor data sheet
Serial.println("");//
Serial.println(temp);//watch the current temperature in serial monitor
bluetooth.println("");//
bluetooth.println(temp);//send temperature to bluetooth device
delay(100);
if (temp <=30){//if temperature is below 30 turn on blue light
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
}
else if (temp >30 && temp <=34){//if temp is above 30 and below 34 turn on green light
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
}
else if (temp >36){//if temperature is above 36 turn on red light
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
}
}