PWM and <IRremote.h>

There is a problem with timers and the IRremoe Lib. I cant use mills() and pwm. Is there any workourand or some ides to solve the problem?

There is a problem with timers and the IRremoe Lib.

What do you think the problem is? In reality, it is probably your code, which you didn't post.

Is there any workourand or some ides to solve the problem?

That all depends on what you think the problem is.

If you read the documentation for the IRremote library you will learn which two pins can't be used for PWM when the IRremote library is in use.

I made an NEC IR library based interrupts, pin 2 or 3 on the UNO.

http://forum.arduino.cc/index.php?topic=317625.0

.

#include <IRremote.h>

/*-----( Declare Constants )-----*/
int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11
int ComErr = 6; 
int offMove = 7; 
int reverseMove = 8;
int MotPwm_1 = 5;


/*-----( Declare objects )-----*/
IRrecv irrecv(receiver);           // create instance of 'irrecv'
decode_results results;            // create instance of 'decode_results'

/*-----( Declare Variables )-----*/

byte rc_order = 0; /* remote order */
byte rc_err_counter = 0;

int motor_v_1 = 5; /* valucity to pwm */
int motor_v_2 = 5; /* valucity to pwm */

int vel = 5;


/* ------------------------------------------------------ */
/* -----------------------( SETUP )----------------------- */
/* ------------------------------------------------------ */

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  /* config / init */
  pinMode(ComErr, OUTPUT);
  pinMode(reverseMove, OUTPUT);
  pinMode(offMove, OUTPUT);
  
  
  
  /* SERIAL */
  Serial.begin(9600);
  Serial.println("YourDuino IR Receiver Button Decode Test");
  Serial.println("Questions: terry@yourduino.com");
  
  /* IR COM */  
  irrecv.enableIRIn(); // Start the receiver
  
}/*--(end setup )---*/

/* ------------------------------------------------------ */
/* -----------------------( LOOP )----------------------- */
/* ------------------------------------------------------ */

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{

 // TimeStamp = millis();
 int test;
  /* ---------- CHECK FOR RECEIVED SIGNAL - CALL FUNCTION TO TRANSLATE HEX CODE ---------- */
        if (irrecv.decode(&results)) // have we received an IR signal?
        {
        Serial.println(results.value, HEX);  //UN Comment to see raw values
        translateIR(); 
        irrecv.resume(); // receive the next value
   //     TimeStampTemp = millis(); /* Safe last order from remote control */
        }   


  
  
    /* -------------------( Diagnostic )------------------- */
            /* Com error */
            digitalWrite(ComErr, LOW); 
            
            if (rc_err_counter  > 15)
            {
                rc_order = 127; 
                digitalWrite(ComErr, HIGH); 
            } 
            
//            /* no button pused 1 second */
//            digitalWrite(offMove, LOW); 
//            
//            if ( TimeStamp - TimeStampTemp > 1500 )
//            {
//               rc_order = 127;
//               digitalWrite(offMove, HIGH); 
//            }
    /* -----------------( MOTOR MOVEMENT )----------------- */
     
     switch(rc_order)
     {
        case  1 :      motor_v_1 = vel; motor_v_2 = vel; break; 
        case  -1:      motor_v_1 = vel; motor_v_2 = vel; break;        
        case  100:     motor_v_1 = 0; motor_v_2 = vel; break;      
        case  200:     motor_v_1 = vel; motor_v_2 = 0; break;   
        default:       motor_v_1 = 0; motor_v_2 = 0; break;      
     }
     /* Set PWM */
        analogWrite( MotPwm_1, (28* motor_v_1) +3  ); /* D3 PWM FUNCTION */

      
}
/* ------------------------------------------------------ */
/* ---------------------( FUNCTIONS )-------------------- */
/* ------------------------------------------------------ */

/* --------------------- translate IR ------------------- */
void translateIR() // takes action based on IR code received
{
  int errActive;
  
  errActive = false;
  
  switch(results.value) // describing KEYES Remote IR codes 
  {  
  /* DIRECTION */
  case 0xFF629D: Serial.println(" FORWARD"); rc_order = 1;  break;
  case 0xFFA857: Serial.println(" REVERSE"); rc_order = -1;  break;
  case 0xFF22DD: Serial.println(" LEFT");    rc_order = 100; break;
  case 0xFFC23D: Serial.println(" RIGHT");   rc_order = 200; break;
  /* STOP */
  case 0xFF02FD: Serial.println(" -OK-");    rc_order = 0;  break; 
  /* SPEED - forward / reward */
  case 0xFF6897: Serial.println(" 1");    vel = 1; break;
  case 0xFF9867: Serial.println(" 2");    vel = 2; break;
  case 0xFFB04F: Serial.println(" 3");    vel = 3; break;
  case 0xFF30CF: Serial.println(" 4");    vel = 4; break;
  case 0xFF18E7: Serial.println(" 5");    vel = 5; break;
  case 0xFF7A85: Serial.println(" 6");    vel = 6; break;
  case 0xFF10EF: Serial.println(" 7");    vel = 7; break;
  case 0xFF38C7: Serial.println(" 8");    vel = 8; break;
  case 0xFF5AA5: Serial.println(" 9");    vel = 9; break;
  case 0xFF4AB5: Serial.println(" 0");    vel = 0; break;
  /* special buttons */
  case 0xFF52AD: Serial.println(" #");    rc_order = 77;  break;
  case 0xFF42BD: Serial.println(" *");    rc_order = 88;  break;
  /* continue operation */
  case 0xFFFFFFFF: Serial.println(" REPEAT"); break;
  /* unknown signal - error */
  default: Serial.println(" other button   "); rc_err_counter ++, errActive = true; break;
  }
  
  
  // delay(500); // Do not get immediate repeat
    
  /* --------------- reset error couonter -------------------*/
  if (errActive == false)
  {
    rc_err_counter = 0;
  }
  
}

Either the Remote control blocks r the pwm doesn´t work depending on the used pwm pin..

I use an nano, that means 3 timers. Timerfunctions don´t work too...

int motor_v_1 = 5; /* valucity to pwm */
int motor_v_2 = 5; /* valucity to pwm */

You don't really expect independent control of motor speeds when you are using only one pin to control both speeds, do you?

 switch(rc_order)
     {
        case  1 :      motor_v_1 = vel; motor_v_2 = vel; break; 
        case  -1:      motor_v_1 = vel; motor_v_2 = vel; break;        
        case  100:     motor_v_1 = 0; motor_v_2 = vel; break;      
        case  200:     motor_v_1 = vel; motor_v_2 = 0; break;   
        default:       motor_v_1 = 0; motor_v_2 = 0; break;      
     }
     /* Set PWM */
        analogWrite( MotPwm_1, (28* motor_v_1) +3  ); /* D3 PWM FUNCTION */

No I don´t thats why I didn´t