It's really nice when you have the control of your fan in your hands....specially in a cold morning..that you do not like to getup form the bed. I will post the details of the schematic later. but its nothing much just replace your regular fan switch with 2/3 relays.
give the relay control to the Arduino board. I have connected 2 relays to the pins 5 and 7 of the Arduino board. and pin 4 for a buzzer. attach the IR sensor head to Pin 11
include IRremote library with the code
*************** source code for Arduino *******************************
// example 32.2 - IR receiver code translator
// for Sony IR codes (ignores 2nd and 3rd signal repeat)
// http://tronixstuff.com/tutorials > chapter 32
// based on code by Ken Shirriff - http://arcfn.com
#include <IRremote.h> // use the library for IR
int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results;
void setup()
{
Serial.begin(9600); // for serial monitor output
irrecv.enableIRIn(); // Start the receiver
pinMode(4, OUTPUT); // beeper
pinMode(5, OUTPUT); // speed 1
pinMode(7, OUTPUT); // speed 2
}
void translateIR()
// takes action based on IR code received
// describing Sony IR codes on LCD module
{
switch(results.value)
{
//case 0x37EE: Serial.println(" Favourite "); break;
//case 0xA90: Serial.println(" Power button "); break;
//case 0x290: Serial.println(" mute ");
// Serial.println(" mute hi ");
// beep();
//break;
case 0x52E9: Serial.println(" one ");
speed1();
beep();
break;
case 0x32E9: Serial.println(" two ");
speed2();
beep();
break;
case 0x12E9: Serial.println(" three ");
off();
break;
//case 0xC10: Serial.println(" four "); break;
//case 0x210: Serial.println(" five "); break;
//case 0xA10: Serial.println(" six "); break;
//case 0x610: Serial.println(" seven "); break;
//case 0xE10: Serial.println(" eight "); break;
//case 0x110: Serial.println(" nine "); break;
//case 0x910: Serial.println(" zero "); break;
//case 0x490: Serial.println(" volume up "); break;
//case 0xC90: Serial.println(" volume down "); break;
//case 0x90: Serial.println(" channel up "); break;
//case 0x890: Serial.println(" channel down "); break;
default: Serial.println(" other button ");
}
delay(500);
}
void beep()
{
digitalWrite (4, HIGH);
delay (50);
digitalWrite (4, LOW);
}
void speed1()
{
digitalWrite (7, LOW);
digitalWrite (5, HIGH);
}
void speed2()
{
digitalWrite (5, LOW);
digitalWrite (7, HIGH);
}
void off()
{
digitalWrite (5, LOW);
digitalWrite (7, LOW);
}
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
translateIR();
for (int z=0; z<2; z++) // ignore 2nd and 3rd signal repeat
{
irrecv.resume(); // receive the next value
}
}
}
******************************************************************************







No comments:
Post a Comment