A tiny Arduino project: Generic IR receiver using ATTiny85 and TL1838

This project uses a small arduino compatible microcontroller board called Digispark which is based on attiny85 chip. It has a PCB usb header which can directly communicate with PC through a USB bootloader. The board is relatively inexpensive compared to regular arduino board. As it comes with a usb connector, no other programmers are needed. It is best suited for projects which require less memory and few i/o pins.

digispark_arduino_irreceiver

Board setup

  • Go to, File->preferences->in ‘Additional Boards Manager URLs’ enter
http://digistump.com/package_digistump_index.json

digispark_setup

  • Go to,  Tools->Board->Boards Manager->Contributed-> Install ‘Digistump AVR Board’

board_manager_digispark

  • Install the drivers from here
  • Tools->Board->Select ‘Digispark (Default – 16.5mhz)’

arduino_digispark

Software

  • Arduino code is here, the irPin is ‘p2’ of board which is connect to IR module TL1838, 300ms debounce time is added to avoid false triggering. There is an inbuilt LED which is connected to ‘p1’ that is turned ON and OFF with the IR pulse.
int irPin=2;
int onoff = 0;

void setup()
{
  pinMode(irPin,INPUT);
  pinMode(1,OUTPUT);
}
 
void loop()
{
  if(pulseIn(irPin,LOW))
  {
    delay(300); // the debounce time 300ms;
    if(onoff == 0)
    {
      digitalWrite(1,HIGH);
      onoff =1;
    }
    else
    {
      digitalWrite(1,LOW);
      onoff =0;
    }
  }
}
  • The code is looking for a low transition on the IR receiver to toggle pin 1, any IR remote can be used since this is a generic receiver which does not actually decode the IR signals.

IRreceiver_arduino_TL1838_digispark

  •  Programming is different from normal arduino boards since USB bootloader is active for first 10s from power on. After 10 seconds the board will switch from bootloader to sketch execution state. The board needs to be plugged-in where the arduino IDE shows notification for programming.

arduino digispark programming

Hardware

  • Pin out of TL1838 is shown below,

1838_ir_sensor_arduino

  • The connection for IR module is shown below, IR input is connected to p2 of the board.

  • Any IR remote can be used to give the signal. Here is the board connected to a usb powerbank and controlled by TV remote

arduino_irsensor