I have a few appliances in different rooms that are controlled via IR. Think of TV sets, settop box, amplifier and LED lamps.
To take control of these i needed just as many remote controles scattered around the house as i have devices.
There had to be a more universal system. This triggered this IR project.
I started with Shirriff's IRremote library for the Arduino.
More info could be found here righto.com/2009/11/ir-bubbles-controlli ... -with.html
As base controller i ordered an Arduino Mega. I know its rather overkill for this project but in the back of my mind
i have the idea that i can use this over capacity later on for other projects. I wired up a receiver setup on breadboard
and took every remote controle i could find and started to record each and every button press in a file. Next i wired
up a IR transmit setup and send out a few codes again to test if they are working, and they did.
In a simple setup you have only one device of each in your house. Put in every room a few IR LED and connect them in parallel.
Blast them with the right signal and your finished. However if you have, like me, two small TV's that are indentical
then both will respond and that is not what you want.
Another problem is reception. The further away the IR led is the weaker the signal and the set just won't respond. To overcome this
last problem i made an 'IR Blaster' for everyroom. Each blaster contains 3 high power wide beam IR leds, 2 high power narrow IR leds
and a small green control led to make visible when a code is send. Each blaster is powered by 12V and controled by an 2n2222
transistor. Because of this higher voltage i needed to seperate this from the 5V powerline used for the Arduino.
The multi room setup i have is solved this way. Please note that the Mega has a different pin numbering
The IR library provide only one pin that can be used to send IR codes. However i want to send IR codes to the blaster i
select based on its location. To do this i made a blaster for each room and switch via a relay the 12V rail to that blaster
circuit. The output of the Arduino is connected to control transistor (2n2222) but only the one that have actually power will
send them out. The one that you use is based on the controle script. To operate the blaster you just send the code information
and the room id, that's it.
Additionally i made a few vbscripts to control everything via VR (voice recognition). Just say "put the television on discovery" and
the script know s in which room the command was said, what type and model of television there is, finds the right code and transmits
it.
Here's the complete Arduino code used
Code: Select all
/*
ZMC ARDUINO v1.0
- IR Control via HomeSeer
Direction : INPUT
Format : I, Protocol type, value, bits, location
IR Output On the 2560 mega this is pin 9 not pin 3
Values for IR protcol_type
#define NEC 1 - In use
#define SONY 2 - In use
#define RC5 3
#define RC6 4 - In use
#define DISH 5
#define SHARP 6
#define PANASONIC 7
#define JVC 8
#define SANYO 9
#define MITSUBISHI 10
#define UNKNOWN -1
*/
#include <IRremote.h>
// these constants won't change:
const byte MAXIRPROTOCOLS = 10;
const byte MAXIRLOCATIONS = 5;
// Assign pin numnbers for the locations
int locations[] = { 0, 22, 23, 25, 24 };
boolean DEBUG = false;
IRsend irsend;
void setup()
{
Serial.begin(9600);
pinMode(9,OUTPUT); // The library initializes pin 3 as an output
digitalWrite(9, LOW); // Since our LED is connected to pin 9,
// we initialize it here
for(int i = 0; i < MAXIRLOCATIONS; i++)
{
if(locations[i] > 0) pinMode(locations[i], OUTPUT);
}
}
void loop() {
// Receiving serial data kicks in here
// Action, byte1, unsigned long, byte3, byte4
serialReceived();
}
void serialReceived() {
// I = IR
// D = Debug On/Off
while (Serial.available() > 0) {
char Action = Serial.read();
int Byte1 = Serial.parseInt();
unsigned long Byte2 = Serial.parseInt();
int Byte3 = Serial.parseInt();
int Byte4 = Serial.parseInt();
if (DEBUG == true)
{
Serial.print("Action = ");
Serial.print(Action);
Serial.print(" Byte1 = ");
Serial.print(Byte1);
Serial.print(" Byte2 = ");
Serial.print(Byte2);
Serial.print(" Byte3 = ");
Serial.print(Byte3);
Serial.print(" Byte4 = ");
Serial.println(Byte4);
}
switch (Action) {
case 'D':
if (Byte1 == 1 )
{
DEBUG = true;
Serial.println("Debugging is ON");
}
else
{
DEBUG = false;
Serial.println("Debugging is OFF");
}
break;
case 'I': // IR command
int location = Byte4;
location = constrain(location, 1, 8);
if(locations[location] > 0) {
digitalWrite(locations[location], HIGH);
delay(400);
// Protocol type, value, bits, location
if ((Byte1 != 0) && (Byte1 <= MAXIRPROTOCOLS)) {
// Type, Value, Bits
DoIR(Byte1, Byte2, Byte3);
}
delay(200);
digitalWrite(locations[location], LOW);
}
break;
}
}
}
// ===============
// == FUNCTIONS ==
// ===============
void DoIR(int type, unsigned long value, int bits){
if(DEBUG == true)
{
Serial.print(" type = ");
Serial.print(type);
Serial.print(" value = ");
Serial.print(value);
Serial.print(" bits = ");
Serial.print(bits);
}
if (type == NEC) {
irsend.sendNEC(value, bits);
}
else if (type == SONY) {
for (int i = 0; i < 3; i++) {
irsend.sendSony(value, bits);
delay(40);
}
}
else if (type == RC5) {
irsend.sendRC5(value, bits);
}
else if (type == RC6) {
irsend.sendRC6(value, bits);
}
else {
Serial.print(type);
Serial.println(" - Undefined IR type !");
}
}