#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 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 0xFF6897: // 0 Button
RGB_LED(255, 255, 255);
lcd.setCursor(0, 0), lcd.print("White: Active ");
lcd.setCursor(0, 1), lcd.print(" ");
break;
case 0xFF30CF: // 1 Button
Indoor_Temp();
irrecv.resume();
break;
case 0xFF18E7: // 2 Button
RGB_LED(0, 255, 0);
lcd.setCursor(0, 0), lcd.print("GREEN: Active ");
lcd.setCursor(0, 1), lcd.print(" ");
break;
case 0xFF7A85:
RGB_LED(0, 0, 255); // 3 Button
lcd.setCursor(0, 0), lcd.print("BLUE: Active ");
lcd.setCursor(0, 1), lcd.print(" ");
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 <= 85)) {
RGB_LED(0, 255, 0);
}
if (Temp > 85) {
RGB_LED(255, 0, 0);
}
}