NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » MY own IR remote emulator

March 25, 2017
by scootergarrett
scootergarrett's Avatar

So to get NetFlix started om my Sony blue ray player; I have to press the power button WAIT, then press the NetFlix button WAIT then the select button. It takes about 1 minute of waiting for things to load. So I made a small nerdkits powered IR remote that at the push of a button will start up NetFlix while I'm free (to help get dinner ready). I used a IR receiver to reverse engineer the digital signal produced by the remote this site helped a lot. I did a lot to make the circuit low power so I could use a coin cell battery. Then designed a PCB to use the 328p QFP chip and stuck the board to the side of my coffie table.

Board

code:

// for NerdKits with ATmega328 //
// This program emulates a Sony remote. When the button is pressed it emulates pressing
// the power button, then pauses then presses the NetFlix Button, then pauses then
// presses the select button. There is a lot of power saving going on.
// The IR "ON" signal is a 40kH square wave, and OFF is just the LED Off
// The protocol is explained here http://www.sbprojects.com/knowledge/ir/sirc.php

// PD2 is input button
// PB2 is to the IR LED
// PB3 is a trouble shooting pin

#include "/home/garrett/Libraries_Mine/Lib.h"

#define TroubleShootPin B,3

#define IRHigh DDRB |= (1<<PB2)
#define IRLow  DDRB &= ~(1<<PB2)

#define ShortWait 570
#define LongWait 1100
#define SonyPower   0b00000000000010101000101101000111      // The power button command
#define SonyNetFlix 0b00000000000011010010101101000111      // The NetFlix button command
#define SonySelect  0b00000000000010111100101101000111      // The select button command

void PWM_INT(void)
{
    /// Set up PWM output on PB2 ///
    DDRB |= (1<<PB2);
    OCR1A = 45;
    TCCR1A = (1<<COM1B1) | (1<<WGM11) | (1<<WGM10);
    TCCR1B = (1<<WGM13) | (1<<WGM12) | (1<<CS11);
    OCR1B = 22;

    IRLow;

    return;
}

void SonyCommend(uint32_t Command)
{
    uint32_t k;
    uint8_t h;

    for(h=0;h<3;++h)
    {
        IRHigh;
        delay_us(2350);
        IRLow;
        delay_us(ShortWait);
        for(k=0b10000000000000000000;k;k>>=1)
        {
            IRHigh;

            if(Command & k)
                delay_us(LongWait);
            else
                delay_us(ShortWait);

            IRLow;
            delay_us(ShortWait);
        }
        delay_ms(12);
    }

    return;
}

int main()
{
    // Set pin state //
    OUTPUT(TroubleShootPin);
    CLEAR(TroubleShootPin);

    PWM_INT();

    // Make PD2 the wake up button interrupt //
    DDRD &= ~(1<<PD2);
    PORTD |= (1<<PD2);
    PCICR |= (1<<PCIE2);
    PCMSK2 |= (1<<PCINT18);
    sei();          // Enable interrupts

    // Save power //
    PRR = (1<<PRTWI)        // turn off TWI
        | (1<<PRTIM2)       // turn off Timer/Counter 2
        | (1<<PRTIM0)       // turn off Timer/Counter 0
        | (1<<PRSPI)        // turn off Serial Peripheral Interface
        | (1<<PRUSART0)     // turn off USART0
        | (1<<PRADC);       // turn off ADC

    // Set sleep mode //
    set_sleep_mode(SLEEP_MODE_PWR_SAVE);
    sleep_mode();

    while(true)
        sleep_mode();

    while(true);

    return 0;
}

/// Wake up Button pressed ///
ISR(PCINT2_vect)
{
    if(!(PIND & (1<<PD2)))
    {
        delay_ms(10);
        SET(TroubleShootPin);

        SonyCommend(SonyPower);
        delay_ms(40000);
        SonyCommend(SonyNetFlix);
        delay_ms(40000);
        SonyCommend(SonySelect);

        CLEAR(TroubleShootPin);
    }

    return;
}
March 25, 2017
by scootergarrett
scootergarrett's Avatar

Cant get the picture to be embeded PIC

March 28, 2017
by Ralphxyz
Ralphxyz's Avatar

Nice looking board!!

Ralph

May 05, 2017
by BobaMosfet
BobaMosfet's Avatar

scootergarrett-

Sweet little board-- don't you LOVE electronics? Well done.

BM

May 21, 2017
by lnino
lnino's Avatar

Nice work. I love projects like that. Well done.

Post a Reply

Please log in to post a reply.

Did you know that microcontrollers have two different kinds of memory, program space (flash) and SRAM? Learn more...