Remote control for the audioamplifier

In the last article I reviewed the remote control based on the RC5 protocol, here I’m going to describe how I added it to my audio-amplifier.

remote control in the audio-amplifier

Have to say, unlike usually, I did not meet any issues with this, so just describing the process.

Firstly, I moved the encoder button from RB0 to other pin and changed the interruption type. Here how it looks like:

if (RBIF) {
GIE = 0;
__delay_ms(100);       //software antibouncing
if (!ebutton) {            //interruption happened AND our button has been pressed
 
...

Then, we need to add the IR commands handler to the main cycle, here we go:

if (bytecount>13)
 {
 GIE = 0;
  if (oldtogglebit != togglebit)          //one button press - one command
   {
     printf("\r\nPressed button is %d", IRbyte);
     switch(IRbyte)
       {
        case 10 : if (!muteIR)            //muting from remote
                    {
                    itemp = 0;
                    volume_flag = 0;
                    mute_status = 0;
                    mute();
                    muteIR = 1;
                    } else
                       {
                        TRISB2 = 1;
                        TRISB1 = 1;
                        volume_flag = 1;
                        bass_flag = 0;
                        treble_flag = 0;
                        menu(0);
                        muteIR = 0;
                        }
                 break;
         case 16 : IRcom = 16; //right
                   break;
         case 17 : IRcom = 17; //left
                   break;
         case 13 : IRcom = 13; //Enter
                   break;
         case 32 : IRcom = 32; //Up
                   break;
         case 33 : IRcom = 33;
                   break;
         case 41 : IRcom = 41; //exit
                   break;
         case 43 : IRcom = 43; //volume+
                   break;
         case 44 : IRcom = 44; //volume-
                   break;
        }
 }
 IRbyte = 0;
 bytecount=0;
 INTEDG = 0;
 buffer = 0;
 oldtogglebit = togglebit;
 GIE = 1;
 }

That’s basically it, other commands added in a similar way.

Leave a Reply

Your email address will not be published.