Gabriele ScordamagliaAntonio Di Bella
Published © GPL3+

IR Remote for Fan

Turn on/off your fan without getting up, just by using an IR remote.

AdvancedFull instructions provided4 hours17
IR Remote for Fan

Things used in this project

Hardware components

Grove - 2-Channel SPDT Relay
Seeed Grove - 2-Channel SPDT Relay
×2
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
IR receiver (generic)
×1
IR Remote
×1
Hi-Link HLK-PM01
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Cable Cutter, 200mm
Cable Cutter, 200mm
Heat Shrinking Tube

Story

Read more

Schematics

cattura_OHt5XH5XdR.PNG

Code

Remote.ino

Arduino
Upload this code and change "YOURCODE" with your IR Remote Code.
Example: 0x"YOURCODE" -> 0xFF30CF
#include <IRremoteInt.h>

#include <IRremote.h> // use the library
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(5, OUTPUT); //IN1 of first Relay
  pinMode(6, OUTPUT); //IN2 of first Relay
  pinMode(7, OUTPUT); //IN1 of second Relay
}
void loop()
{
  if (irrecv.decode(&results)) // have we received an IR signal?
  {
    Serial.println(results.value, HEX); // display it on serial monitor in hexadecimal
    irrecv.resume();// receive the next value
  }
 
 //Check if other Relays are OFF before turning ON the one selected.
  if (results.value == 0x"YOURCODE1"){ 
    if (digitalRead(6) == LOW && digitalRead(7) == LOW) {
    digitalWrite(5, HIGH); 
  }
    else if(digitalRead(6) == HIGH || digitalRead(7) == HIGH) {
      digitalWrite(6, LOW);
      digitalWrite(7, LOW);
      delay(1000); //Wait a sec just to be sure of not causing a short circuit
      digitalWrite(5, HIGH);
    }
  }
  
 if ( results.value == 0x"YOURCODE2"){ 
  if (digitalRead(5) == LOW && digitalRead(7) == LOW) {
    digitalWrite(6, HIGH); 
  }
  else if(digitalRead(5) == HIGH || digitalRead(7) == HIGH) {
      digitalWrite(5, LOW);
      digitalWrite(7, LOW);
      delay(1000);
      digitalWrite(6, HIGH);
    }
 }  

 if ( results.value == 0x"YOURCODE3"){ 
  if (digitalRead(5) == LOW && digitalRead(6) == LOW) {
    digitalWrite(7, HIGH); 
  }
  else if(digitalRead(5) == HIGH || digitalRead(6) == HIGH) {
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(1000);
      digitalWrite(7, HIGH);
    }
 }  

// Put here your code for turning off the Fan
 if ( results.value == 0x"YOURCODE4"){
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
 }

}

Decoder.ino

Arduino
Use this code to read and store your remote's code
#include <IRremoteInt.h>

#include <IRremote.h> // use the library
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(9, OUTPUT); // Pin 9 output
}
void loop()
{
  if (irrecv.decode(&results)) // have we received an IR signal?
  {
    Serial.println(results.value, HEX); // display it on serial monitor in hexadecimal
    irrecv.resume();// receive the next value
  }
   
}

Credits

Gabriele Scordamaglia

Gabriele Scordamaglia

4 projects • 33 followers
20 YO, Electronics Engineering student in Italy.
Antonio Di Bella

Antonio Di Bella

0 projects • 1 follower

Comments

Add projectSign up / Login