SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By clone_
#194947
Hello, Need help for 2 problem that y have with this code that y put together , fist problem is that y cant seems to be able to make the (PowerSB Raw code ) to work, all the Oder code are transmitting fine, y suspect it is the length of the Raw code that is a problem,

The second issue that y have is that y not able to repeat a code, if y do a one click it works fine but since this code is for controlling the volume of the SB y want to be able to hold the volume Up or down for the desire level, try to play with delays but it did not do a good job, the code y have doesnt have a repeat FFFFF code

Thanks for your help :D
Code: Select all
/*   translator Remote Control for Samsung Soundbase
.



*/
#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
IRsend irsend; //for some reason always on pin 3?

#define Power_TV 3772793023 //E0E040BF
#define Mute_TV 3772837903 //E0E0F00F
#define Volume_Up_TV 3772833823 //E0E0E01F
#define VolumeDown_Tv 3772829743 //E0E0D02F


unsigned int  MuteSB[77] = {4700,4200, 700,300, 700,300, 700,300, 700,300, 650,1300, 700,1250, 650,350, 650,350, 650,1300, 650,1300, 650,1300, 650,1300, 650,350, 650,350, 650,350, 650,300, 650,4350, 600,350, 650,350, 650,350, 650,350, 600,1350, 650,350, 600,400, 600,350, 650,1300, 650,1350, 600,1350, 600,400, 600,350, 650,1300, 650,1350, 600,1350, 600,350, 650,350, 650,350, 650,1300, 650}; 
unsigned int  PowerSB[99] = {3650,1500, 650,250, 600,1100, 650,250, 600,250, 600,250, 600,250, 600,250, 650,250, 600,250, 600,250, 600,250, 600,300, 550,300, 550,1150, 600,250, 600,300, 550,300, 550,300, 600,250, 600,250, 600,300, 550,300, 550,300, 550,1150, 600,300, 550,300, 550,300, 550,300, 550,350, 550,300, 550,300, 550,300, 550,1200, 550,300, 550,1150, 550,1200, 550,1150, 550,1150, 600,300, 550,300, 550,1150, 550,350, 550,1150, 550,1150, 550,1200, 550,1150, 550,350, 500,1200, 550}; 
unsigned int  VolumeUp[77] = {4700,4200, 750,300, 650,300, 700,300, 700,300, 650,1300, 700,1250, 700,300, 650,350, 650,1250, 700,1300, 650,1300, 650,1300, 650,350, 650,350, 650,350, 650,300, 650,4300, 650,350, 650,350, 650,350, 650,350, 600,1350, 600,1350, 600,1350, 650,350, 600,1350, 600,1350, 600,1350, 650,350, 600,400, 600,400, 600,350, 650,1300, 650,350, 650,350, 600,400, 600,1350, 600};
unsigned int  VolumeDown[77] = {4650,4250, 700,300, 700,300, 700,300, 650,350, 650,1300, 650,1300, 650,350, 650,350, 650,1300, 650,1300, 650,1300, 650,1300, 650,350, 600,400, 600,350, 650,350, 650,4300, 650,350, 650,350, 600,400, 600,350, 650,350, 650,400, 600,350, 600,1350, 600,1400, 600,1350, 600,1350, 600,400, 600,1350, 600,1350, 600,1350, 600,400, 600,350, 600,400, 600,400, 600,1350, 600};  






void setup()
{
    irrecv.enableIRIn(); // Start the receiver
    irrecv.blink13(1);
}

void loop() {
  if (irrecv.decode(&results)) { 
    delay(4); 
    switch (results.value) {
      case Power_TV:
        //Do this when the middle button is pressed
        irsend.sendRaw(PowerSB,99,48);
        irrecv.enableIRIn(); 
      
        break;
      case Volume_Up_TV:
        irsend.sendRaw(VolumeUp,77,32);
        irrecv.enableIRIn(); // because irsend disables irrecv
       
        break;
      case Mute_TV:
        
        irsend.sendRaw(MuteSB,77,32);
        irrecv.enableIRIn(); // because irsend disables irrecv
        break;
        
      case VolumeDown_Tv :
       
        irsend.sendRaw(VolumeDown,77,32);
        irrecv.enableIRIn(); // because irsend disables irrecv
      
        break;
      
      
    } 
    irrecv.resume(); 
  }
}