4-Channel IR Remote Control System Using ATtiny85

Today’s project is about a basic 4-Channel IR Remote Control System Using ATtiny85 Microcontroller which can drive AC loads easily. The input signals are sent from a transmitter (Any Infrared Remote) using IR transmission and received by an IR receiver. On the receiver side, we use a simple and compact ATtiny85 chip for a simpler look at the circuit. We have previously discussed how to upload Arduino code into ATtiny85 without using any Arduino. Go and check it out.

Principle Behind IR Remote Control System

The main working principle behind this circuit is infrared communication. IR communication uses IR signals to transmit signals as a carrier. The input signals of the transmitter switches are processed by the microcontroller first, then it is encoded by the encoder. After that is modulated and transmitted by the transmitter.

Next, the transmitted signal will be demodulated by the IR receiver and decoded by ATtiny85 to control the loads.

Project

Circuit Diagram

4-Channel IR Remote Control System Circuit Diagram
4-Channel IR Remote Control System Circuit Diagram

Components Required

  • Arduino Board (Any)
  • ATtiny85 Microcontroller
  • TSOP1738 Infrared Sensor
  • 7805 Voltage Regulator
  • 5V Relay Module (x4)
  • BC547 NPN Transistor (x4)
  • 1N4007 PN Diode (x4)
  • Resistor (1K, 560, 100)
  • Polar Capacitor (100uF/25V, 47uF/25V)
  • 0.1uF Ceramic Capacitor
  • 2-Screw Terminal (x5)
  • Wires
  • 12V Power Supply

PCB Design

For removing messy wiring and give a clean look, I designed a PCB prototype for this project. It is also helpful for troubleshooting that runs great without any errors. To design this PCB board, I used EasyEDA as it is too easy to use. For ordering PCB for this, I personally prefer PCBWay.

Gerber file for 4-Channel IR Remote Control System Gerber.

You can view the Gerber file from here Gerber File Viewer.

PCB View

4-Channel IR Remote Control System 2D
2D View
4-Channel IR Remote Control System 3D
3D View

Order PCB From PCBWay

This project is sponsored by PCBWay.com. PCBs are required everywhere in the electronics industry. So it needs to be good enough and have to serve the purpose for which they are needed without costing exorbitant amounts. PCBway offers all your needs come true. PCBWay is one of the largest PCB (Printed Circuit Board) manufacturing companies in china. It offers PCB prototype, PCB Assembly, SMD Stencil, and Flexible PCB.

They ship to more than 170 countries worldwide and process more than 2100 PCB orders a day. It feels like PCBWay gives an excellent price and customer service factor in one single serving. I personally ordered PCBs from PCBWay for my projects for just 5 dollars. I’ve used other PCB manufacturers too, but PCBWay has been offering the most reliable and consistent that I have tried. What is also spectacular about PCBWay to me, as a maker and customer, is their service. From their friendly support staff to their intuitive, user-friendly website features, it all counts towards what makes PCBWay an ideal company and brand for any electronics hobbyists.

Standard quality for any product needs to be maintained using some parameters. PCBWay gives that opportunity by quality control in designing and manufacturing. At first, they ensure accuracy, clarity, validity of the PCB files that we sent to them.

Then all the boards will go through the most stringent tests other than the basic visual check. They adopt most of the testing and inspecting equipment used in the industry, such as Flying Probe Tester, X-Ray Inspection Machine, Automated Optical Inspection (AOI) Machine. PCBWay are having 50+ new engineers on the daily basis around the world using PCBs for their work, who trust for their reliable quality. They produce high-quality pink, orange, grey, even transparent solder mask. Moreover, according to people needs, they can also provide Black core PCB. Check it out for a High-Quality PCB solder mask. There are some pictures below of the new colours of solder musks.

Features of PCBWay

PCB Prototyping & Manufacturing: PCBWay produces FR-4 and Aluminum boards and advanced PCBs like Rogers, HDI, Flexible and Rigid-Flex boards, at a very reasonable price. Just check this Instant Quote to order premium PCBs for your hobby projects.

PCB Assembly: It not only offers PCB Prototyping but also offers PCB Assembly service. You can order a full PCB board with attached components by uploading your file. SMT & THT assembly starts from only 30$ including free stencil and worldwide shipping. The components can be sourced and provided by PCBWay, or by clients themselves.

Open Source Community: It not only offers PCB Prototype & Assembly service but also gives opportunities to students for sponsorships. I think this is so great. They feature their projects on the website also.

3D Printing & CNC: It also produces Rapid Prototyping like 3D printing, CNC Machining, Sheet Metal Fabrication, and Injection Molding. The quality of the product is too premium and reliable. And also the best part is that you will receive your order within a minimum of 3 days.

Services: PCBWay offers great servicing of their products. It takes only 3 to 15 days according to courier service to deliver your products. Also, it has a live support facility. Whenever you have any problems, you can always reach a live customer service person to respond to your emails or messages. They have the “Return and Refund” principle, for every unusable board caused by PCBWay, they will rebuild and refund the order soon.

Guide for Ordering PCB From PCBWay

Modulation of IR Signals

Modulation of IR signal is important because there are many other sources of infrared rays when the IR receiver receives the signals. Almost everything that emits heat also emits infrared rays. So the signals from a remote can be interfered with by anything from sunlight, light bulbs and even our own bodies. Here we need to take some measures to ensure that the IR signals will be received by the receiver without any errors.

Now the wave pulses from the IR LEDs have to be modulated just like analog radio modulates a carrier wave to send a signal. To make the IR LED transmit with a particular frequency, modulation involves here. Then the IR receiver will also work with that frequency in order to ignore the noise signals from other infrared sources.

The encoder part of the remote converts a binary signal into a modulated electrical signal. This electrical signal is then sent to the transmitter. It converts the modulated electrical signal into a modulated infrared signal. The IR receiver then demodulates the infrared signal and converts it back to the binary signal before processing it to the microcontroller.

Normally IR remotes use a modulation frequency of 38kHz. There are few other sources that have a frequency of 38kHz signal. IR receivers are designed to receive these modulated infrared rays and to ignore all other noise signals of surroundings. The infrared ray covers a broad range of spectrums (700nm to 1mm). Most IR LEDs used in remotes operate between 850nm to 940nm range, so most receivers are tuned to receive the rays within this range. This is another way that how it prevents interference from sunlight and other infrared sources.

Decoding of IR Remote Using Arduino

There is important to decode IR code after modulation of the infrared signal. This is done by knowing the control codes of the remote control because each key of the IR remote generates a unique hexadecimal code that is modulated and sent to the IR receiver.

4-channel IR remote decoding circuit

In absence of a specific code datasheet, we can simply use an Arduino to easily crack the specific code on the serial monitor. Below the basic circuit diagram and circuit, a connection is shown using the TSOP1738 IR sensor and Arduino Nano.

Arduino Code for Decoding IR Codes

First of all, we need a Library file to run the IR code extractor program i.e. IRremote.h library.

#include <IRremote.h>

int IRpin = 2;
IRrecv irrecv(IRpin);
decode_results results;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
}

void loop()
{
if (irrecv.decode(&results))
{
Serial.println(results.value, DEC);
irrecv.resume();
}

}

From the serial monitor, we got the specific values of each needed key in decimal values. The long values are negligible, only the short ones are considered. After decoding the remote keys, we can use them in many applications. For example, controlling the home appliances using Arduino.

Working Principle of 4-Channel IR Remote Control System

An infrared remote contains an IR LED that produces wave pulses to send signals to another device. On the other hand, an IR receiver receives these infrared waves for decoding the signals. An infrared receiver contains a photodiode and an amplifier for converting the infrared signals to electrical signals.

IR remote has different keys whereby each key produces a different wave pulse when pressed. The transmitting IR LED will blink very quickly for a fraction of a second when we press any of these buttons. These wave pulses (encoded data) can then be decoded uniquely by the IR receiver so that a specific action can be done, such that changing one channel from another.

Arduino Code

Learn how to upload code into the ATtiny85 microcontroller without Arduino.

const int irPin = 4;
const int Relay1 = 0;
const int Relay2 = 1;
const int Relay3 = 2;
const int Relay4 = 3;
boolean Relay1State = false;
boolean Relay2State = false;
boolean Relay3State = false;
boolean Relay4State = false;
void setup() {
  
  //Serial.begin(115200);
  pinMode(irPin, INPUT);
  
pinMode(Relay1, OUTPUT);
pinMode(Relay2, OUTPUT);
pinMode(Relay3, OUTPUT);
pinMode(Relay4, OUTPUT);
}
void loop() {
  int key = getIrKey();
  
  if(key ==  1 ){
    Relay1State = !Relay1State;
    if(Relay1State == true)
      digitalWrite(Relay1, HIGH);
    else
      digitalWrite(Relay1, LOW);
  }
  
  if(key == 2 ){
    Relay2State = !Relay2State;
    if(Relay2State == true)
      digitalWrite(Relay2, HIGH);
    else
      digitalWrite(Relay2, LOW);
  }
 
  if(key ==  3 ){
   
    Relay3State = !Relay3State;
    if(Relay3State == true)
      digitalWrite(Relay3, HIGH);
    else
      digitalWrite(Relay3, LOW);
  }
   if(key == 4  ){
    
    Relay4State = !Relay4State;
    if(Relay4State == true)
      digitalWrite(Relay4, HIGH);
    else
      digitalWrite(Relay4, LOW);
  }
}
int getIrKey(){
  int len = pulseIn(irPin,LOW);
  int key, temp;
  key = 0;
  //Serial.print("len=");
  //Serial.println(len);
  if(len > 5000) {
    for(int i=1;i<=32;i++){
      temp = pulseIn(irPin,HIGH);
      if(temp > 1000)
        key = key + (1<<(i-17));
    }
  }
  if(key < 0 )
    key = -key;
  
  //if(key)
    //Serial.println(key);
    delay(250);
  return key;
}

Leave a Comment