In this article, we are going to make our own remote-controlled device using SONY SIRC remote protocol. In the previous article, we have learned the basic pattern of this protocol and now we will use that in our circuit. We’ll use PIC12F675 micro-controller and mikroC Pro for the PIC compiler. Let’s make our ‘SONY SIRC Remote Controlled device using PIC Micro-controller and mikroC’.
⚠️ Disclaimer ⚠️
Working with electricity involves serious risk. Ensure you have the necessary skills and take proper safety precautions before attempting any electrical projects. Proceed at your own risk — the author assumes no responsibility for any damage, injury, or issues resulting from the use or misuse of the information provided.
All content on this website is original and protected by copyright. Please do not copy or reproduce content without permission. While most of the resources shared here are open-source and freely accessible for your learning and benefit, your respect for our intellectual effort is appreciated.
If you find our tutorials helpful, consider supporting us by purchasing related materials or sharing our work — it helps keep the content flowing.
Need help or have questions? Leave a comment below — the author is always happy to assist!
Table of Contents
About SONY SIRC:
In my previous article, I’ve explained this protocol. Please read that article first to learn about SONY SIRC. SIRC protocol is one of the most common protocols in remote-controlled systems. This protocol uses a start bit, then a command, and then an address bit. All these are transmitted at 40KHz modulation. A remote sensor is used to receive that modulated signal and decode the pattern. After that, micro-controllers are used further to decode the command and address from that received signal.
Circuit Diagram:
MikroC Code with the library:
Here is the library of the SONY SIRC remote decoder. I used mikroC pro for PIC with a valid license. If you are having a problem building the hex let me know.
sbit ir_rx at GP3_bit; // Sensor pin // function prototypes void get_mark_time(void); // global variables unsigned char counter = 0; unsigned char bitcount; unsigned char ir_address; unsigned char ir_command; unsigned int mark_time; void interrupt() iv 0x0004 ics ICS_AUTO { if (TMR0IF_bit) { counter++; // increment counter TMR0IF_bit = 0; // Clear Timer0 overflow interrupt flag } } void main() { CMCON = 0x07; // disable comparator ANSEL = 0x00; // disable analogue OPTION_REG = 0x03; // TMR0 prescaler set to 1:16 TRISIO = 0x08; // IR GP3 = input, rest output GPIO = 0x00; // all outputs off // start timer 0 counting GIE_bit = 1; // Global interrupt enable T0IE_bit = 1; // Enable Timer0 overflow interrupt while(1) { ir_command = 0; ir_address = 0; get_mark_time(); if ((mark_time > 120) && (mark_time < 200)) // set the frequency limit { for(bitcount = 0 ; bitcount < 7 ; bitcount++) { get_mark_time(); // get a Sony IR bit ir_command >>= 1; // shift ir_command &= 0x7f; // top bit zero if (mark_time > 0x40) { ir_command ^= 0x80; // top bit 1 } } ir_command >>= 1; // shift 1 unused bit ir_command &= 0x7F; // clear top bit for(bitcount = 0 ; bitcount < 5 ; bitcount++) { get_mark_time(); // get a Sony IR bit ir_address >>= 1; // shift ir_address &= 0x7f; // top bit zero if (mark_time > 0x40) { ir_address ^= 0x80; // top bit 1 } } ir_address >>= 3; // shift 3 unused bits ir_address &= 0x1F; // clear top 3 bits } if(ir_address == 1) { // TV if(ir_command == 0) { // button 1 GP0_bit = ~GP0_bit; } if(ir_command == 1) { // button 2 GP1_bit = ~GP1_bit; } if(ir_command == 2) { // button 3 GP2_bit = ~GP2_bit; } Delay_ms(200); // avoid double toggle } } } // get time of mark, then ignore space void get_mark_time(void) { while(ir_rx); // wait for a mark counter=0; TMR0 = 0; while(!ir_rx); // wait for space mark_time = (counter << 8) + TMR0; // collect integer mark time }
Download the hex file instead.
Test result:
I’ve made a video for this purpose. Please play this video.
Conclusion:
I hope this project was helpful to you. If you make one for yourself, it will be a great pleasure for me. Anywhere you need help, let me know. Please share this project and subscribe to my blog. Thank you.
Liked this article? Subscribe to our newsletter:
or,
Visit LabProjectsBD.com for more inspiring projects and tutorials.
Thank you!
Check this out: 5 coolest multimeters you can buy
3 Comments
Ajape · 18/03/2021 at 9:44 am
thank you for the new development, more grace to you
Joy · 29/03/2021 at 1:26 am
Sir i want change remote but what can i do ?.
Mithun K. Das · 29/03/2021 at 8:04 am
Add code for a different protocol.