Can't read IR codes when tlc.init() is in setup()

Howdy,

when "tlc.init()" line is not commented in setup() function, I can't read IR codes. I had the IR pin on 2, 5, 7 but same result. Any ideeas why?

Here is my code:

#include <WProgram.h>
#include <NECIRrcv.h>
#include "Tlc5940.h"


#define IRPIN 5    // IR receiver pin
                    

NECIRrcv ir(IRPIN) ;

void setup()
{
  Serial.begin(9600) ;
  Serial.println("NEC IR code reception") ;
  ir.begin() ;
  Tlc.init();
}

void loop()
{
  while (ir.available()) Read_IR_Code(ir.read());
}



void Read_IR_Code(unsigned long IR_Code)
{
  switch (IR_Code)
    {
    case 4228116224:    // ON button
      f_ON();
      break;
      case 4244827904:  // OFF button
      f_OFF();
      break;
    case 4261539584:    // Dimm - button
      f_DIMM_Minus();
      break;
    case 4278251264:    // Dimm + button
      f_DIMM_Plus();
      break;
    case 4161269504:    // W button
      f_W();
      break;
    case 4177981184:    // B button
      f_B();
      break;
    case 4194692864:    // G button
      f_G();
    case 4211404544:    // R button
      f_B();
      break;
    case 4094422784:    // Flash button
      f_Flash();
      break;
    case 4027576064:    // Strobe button
      f_Strobe();
      break;
    case 3960729344:    // Fade button
      f_Fade();
      break;
    case 3893882624:    // Smooth button
      f_Smooth();
      break;
    case 4144557824:    // Red colour button
      f_Red_Colour();
      break;
    case 4127846144:    // Green colour button
      f_Green_Colour();
      break;
    case 4111134464:    // Blue colour button
      f_Blue_Colour();
      break;
    case 4077711104:    // User (1,1) colour button
      f_User_1_1();
      break;      
    case 4060999424:    // User (1,2) colour button
      f_User_1_2();
      break;      
    case 4044287744:    // User (1,3) colour button
      f_User_1_3();
      break;      
    case 4010864384:    // User (2,1) colour button
      f_User_2_1();
      break;      
    case 3994152704:    // User (2,2) colour button
      f_User_2_2();
      break;      
    case 3977441024:    // User (2,3) colour button
      f_User_2_3();
      break;      
    case 3944017664:    // User (3,1) colour button
      f_User_3_1();
      break;      
    case 3927305984:    // User (3,2) colour button
      f_User_3_2();
      break;      
    case 3910594304:    // User (3,3) colour button
      f_User_3_3();
      break;      
    }
}



void f_ON()
{
      Serial.println("ON");  
}

void f_OFF()
{
      Serial.println("OFF");  
}

void f_DIMM_Minus()
{
      Serial.println("Dimm -");
}

void f_DIMM_Plus()
{
      Serial.println("Dimm +");
}

void f_W()
{
        Serial.println("W");
}

void f_B()
{
        Serial.println("B");
}

void f_G()
{
        Serial.println("G");
}

void f_R()
{
        Serial.println("R");
}

void f_Flash()
{
        Serial.println("Flash");
}

void f_Strobe()
{
        Serial.println("Strobe");
}

void f_Fade()
{
        Serial.println("Fade");
}

void f_Smooth()
{
        Serial.println("Smooth");
}

void f_Red_Colour()
{
        Serial.println("Red colour");
}

void f_Green_Colour()
{
        Serial.println("Green colour");
}

void f_Blue_Colour()
{
        Serial.println("Blue colour");
}

void f_User_1_1()
{
        Serial.println("User 1,1");
}

void f_User_1_2()
{
        Serial.println("User 1,2");
}

void f_User_1_3()
{
        Serial.println("User 1,3");
}

void f_User_2_1()
{
        Serial.println("User 2,1");
}

void f_User_2_2()
{
        Serial.println("User 2,2");
}

void f_User_2_3()
{
        Serial.println("User 2,3");
}

void f_User_3_1()
{
        Serial.println("User 3,1");
}

void f_User_3_2()
{
        Serial.println("User 3,2");
}

void f_User_3_3()
{
        Serial.println("User 3,3");
}

Check to see if NECIRrcv uses any of the same pins or timers as the TLC5940.
I know the TLC5940 uses one of the timers generating a regular interrupt to do its background task of refreshing the chip. It sound like both libraries need the same resource.

When posting code please post it between the brackets that come up with the # icon in the reply box. It makes it so much easer to read.

I looked in both libraries and, as a begginer, I saw that only pin 13 was used by the libraries. I deleted in NECIRrcv the lines regarding pin 13, but the problem was not solved. Managed someone to make this two libraries working together?

I wish I could offer some more detailed information.. I'll leave that to GrumpyMike, but I believe they do both use the same Interrupt.

I've used the IR library, and read somewhere that it is based on the interrupt timer.. but I've never set up my own interrupts, so I'm not sure how to get the two to work together(this is where GrumpyMike comes in:P)

I'm not sure if they're both based off the same Interrupt, but check out this library here. It can send, and receive IR codes.

Read down a bit and he explains it for the most part!

Anyways, best of luck, and do keep us updated if you get it figured out, so others can look here for a reference when they have problems:D

I tried it already, but it seems that interfears also with the TLC library. I give no commands for leds but these are becomming active after i download the IRrecvDemo example programm in the uC.

try checking your setup() function

Just saw that TLC5940 library uses 2 timers and NECIRrecv 1. As atmel328 uC has 2 timers, these two libraries can't work together. Am I right?

The solution i used is that i wrote a function that uses a hardware interrupt to read the IR codes instead using the NECIRrcv library.