Problem with Arduino Temperature sensor with LCD and IR Remote control

I'm trying to make the LCD constantly display the rooms temperature and with the press of a button change to a simulated "Outdoor temp".

I cant find a way to consistently update the LCD with the Temperature readings without having to press the button on my remote to update it. I know my code is ruff I'm sorry.

#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>
#include <LiquidCrystal.h>

int RECV_PIN = 6; // IRreciever Pin
IRrecv irrecv(RECV_PIN);
decode_results results;
const int Temp_Sensor = 5; // Temp Sensor Pin
const int Out_Temp = 0;
const int Red_Pin = 8;
const int Green_Pin = 9; // RGB Pins
const int Blue_Pin = 10;
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; //LCD Pins
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
float Temp;

void setup()
{
lcd.begin(16, 2); // Number of Columns and Rows on the LCD
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(Red_Pin, OUTPUT);
pinMode(Green_Pin, OUTPUT);
pinMode(Blue_Pin, OUTPUT);
}

void loop()
{
if (irrecv.decode(&results))
{
RemoteIR();
irrecv.resume();
}
}

void RemoteIR() // Function for the Ir remote
{
switch (results.value)
{

case 0xFF30CF: // 1 Button
Indoor_Temp();
break;

case 0xFF18E7: // 2 Button
Outdoor_Temp();
break;

default:
break;
}
}

void RGB_LED(int Red, int Green, int Blue) // Function for the LED
{
analogWrite(Red_Pin, Red);
analogWrite(Green_Pin, Green);
analogWrite(Blue_Pin, Blue);
}

void Indoor_Temp() // LM35 Temp Sensor Function
{

Temp = analogRead(Temp_Sensor);
Temp = Temp * 0.48828125;
Temp = (Temp * 1.8) + 32;
lcd.setCursor(0, 0), lcd.print(" ");
lcd.setCursor(0, 1), lcd.print("Temp: "), lcd.print(Temp), lcd.print("F ");

if (Temp <= 65) {
RGB_LED(0, 0, 255);
}
if ((Temp > 60) && (Temp <= 80)) {
RGB_LED(0, 255, 0);
}
if (Temp > 80) {
RGB_LED(255, 0, 0);
}

}

void Outdoor_Temp() //Potentiometer to simulate outdoor temp Function
{

Temp = analogRead(Out_Temp);
Temp = Temp * 0.1;
lcd.setCursor(0, 0), lcd.print(" ");
lcd.setCursor(0, 1), lcd.print("Temp: "), lcd.print(Temp), lcd.print("F ");

if (Temp <= 65) {
RGB_LED(0, 0, 255);
}
if ((Temp > 60) && (Temp <= 80)) {
RGB_LED(0, 255, 0);
}
if (Temp > 80) {
RGB_LED(255, 0, 0);
}

}

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you explain what you have , ie IR transmitter, IR Receiver .
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile: