Can I use multiple receivers in the IR library.

I have been playing with the IR library and I have a project that is a little out of the ordinary. I can not find a post or article on using multiple receivers on a single Arduino. Why you ask? Well I am trying to use a ir sensor to acknowledge a hit on a target. This is simple for one target, but I would like to have 10 targets. The mega has 12 pwm pins I originally thought this would be easy, but now realize I need some help. I have looked in the library and found what timers control what pins and that I can modify the library to change the timers.... Am I on the right track or is it possible for a rookie programmer as myself. 1) Can anyone let me know if it is possible. 2) does anyone know of an article that would help me out. Thanks in advance!

You have an object with 10 targets, like 10 goals ?
And you would want to know if one of them is hit and which one ?

Can you give a link to that library ?

It will be hard. I doubt if it can be done. Perhaps the creator of the library can do that.
You could use 10 very small and cheap Arduino boards, like the Pro Mini.

Is this an IR remote control library or just a there or not there IR sensor library.

If you need to decode a signal from the shot it could be hard to use more than one per Arduino as these libraries tend to be very timing dependent and one of them will usually lay dibs to timer 2. As much as I don't like it, it the multiple Arduino method might be the most straight forward. I would see if I could get a library working on an ATTiny chip and use a lot of them. That said, if you go this way be sure to add a crystal to each ATTiny, as the built-in oscillator is often too inaccurate to get good IR data.

Thanks Guys for responding. The library I was referring to is the standard IR library from Ken Sheriff. I have already built a prototype with a nano as a firing device and a mega as the receiving Arduino. I am just stumbling on the second receive pin. As jroorda said they use the timer 2, but each timer controls multiple pins and there are 12 PWM available. Why wouldn't it be possible? I did think of using multiple nanos and coupling them together to create a score. but I think it would be tidier if I cold keep it to one mega.

The Google Machine wins again.

It looks like the author of that library has addressed the issue himself. Here is what he had to say:

To outline what you’d need to do to support multiple independent IR receivers…
The code currently uses a single irparams global structure to keep track of the received code. The timer 2 interrupt code checks the status of the input pin and updates the irparams structure.
You’d need a separate irparams structure for each pin. You could have an array of them, or maybe have irparams part of the IRrecv class. The array would make it easier for the interrupt handler, but putting it in the class would be architecturally cleaner. Then the interrupt code would need to loop through all of them, updating each one according to the input.
Then the decoding routines would need to process a particular irparams structure, rather than the global one.
I’m not sure how many inputs you could process before you’d run out of time in the interrupt handler.

Check the comments here: A Multi-Protocol Infrared Remote Library for the Arduino

It looks like he made a modified version of the code that takes these changes into account and there is a link to it about half way down the comments. I’ll let you explore from here, but this should get you started.

wow Thank you for that. I have been on his blog several times and I missed that. I will have to decipher all of what was said and give it a whirl. I have written some code with different receive parameters and moved them around. I was successful in moving the pin but not getting two to work. Thanks again I feel more confident in knowing that it is possible and I may not come out with a bloody forehead.

What sort of receiver are you using?
If you just need to register a hit ( is it a shooting game ) then there is no need to decode the incoming IR data and so no need to use the library at all.
Just connect each receiver to it's own input pin and poll them ( look at them in turn ) for any pulsing activity.

I am using a TSOP4838.

Yes it is like a shooting game, but with a twist. there maybe up to 4 shooters and there is where the code comes in. I also will be sending low battery code from the shooting device. So identification and counting hits for each device is crucial. Thanks

Hello all,

I found this Post so i will give a try, maybe some one will help me, no one reply to my post's.
So lately i found out that i have a IR reciver with wavelength 700nm to 1000nm, but with that wavelength i found out with the simple
example code from the arduino software, " Analog Read Serial " that my IR reciver is sensitive to "visible light" i mean to normal room light or sun light, so my question is if i buy a 940nm IR reciver, that reciver will be sensitive to "visible light" or just from other led with the same wavelength "940nm" ???

What i actualy need is a IR reciver (i think 940nm) that will recive only IR light by reflecting from other objects (other story), but not "room light" & "sun light"

Thanks.

Domino60:
......
What i actualy need is a IR reciver (i think 940nm) that will recive only IR light by reflecting from other objects (other story), but not "room light" & "sun light"
Thanks.

Think about it.
How should the IR-receiver know the difference?
Unless you do something to "make your IR stand out from the rest", there is no way the sensor can know what to look for.

By modulating the signal, and making the receiver or data handling specific for that modulation, you are able to distinguish "signal" from background.

How should the IR-receiver know the difference?

Well there is no some kind of IR recivers with "filter" that recive only at 940nm infrared light ?

able to distinguish "signal" from background.

1st i don't know that wavelength of my 2pin's IR receiver, i searched and i think its from 700nm to 1000nm,
but i wana talk about the 940nm IR recivers that many sell on ebay.
Well i wrote a code that will receive only a "amount" of analog singal ->
and even if the IR receive directly "lamp room light" or "sun light" the code will cut that, lets see below

// IR

But there is still a problem, even if i cover the IR reciver with some kind of plastic that will recive the light only from
"arpprox : "angle of 20 degrees or so, the "room light" maybe somehow have a effect in that 20 degrees so i dont have what i need.

What i actualy wana say is, ex. we have a IR door sensor for "thieves" and if i turn on my room lights, the light will have a effect
in the IR sensor, and maybe tern on the alarm , (Yes i know there is may, many ways to cover the IR sensors...etc) But what i need is that IR sensor and IR transmiter (RX-TX) to be close to eachother and be activated by some kind of material passing above them, Like the IR cars that follow a black line.

I hope i was clear, if not reply and help me with some kind of advices.
Thanks

Domino60:
Well there is no some kind of IR recivers with "filter" that recive only at 940nm infrared light ?
.....

I hope i was clear, if not reply and help me with some kind of advices.
Thanks

And how should the IR sensor be able to distinguish "your 940 nm IR" from "any other 940nm IR".

Either you code/modulate it, or make sure, that your IR source is significantly stronger than the background radiation.
Your sensor must be able to detect something (like a significant drop in intensity), otherwise how will you feed any useful input to your code?

No, you were not very clear. Please tell the whole story!

Domino60:
Well there is no some kind of IR receivers with “filter” that receive only at 940nm infrared light ?

Optical filters are generally very broad, and a close source of a quite different wavelength will likely get through as well as a distant source of the specified wavelength. This applies just as much to the filtering material incorporated in the IR detector itself.

The other problem is that the filter attenuates the desired wavelength to some extent, so adding more filters reduces sensitivity.

Well as i understand the best way if you need to know something, is to test it, no one gave me the answer that i needed.

Domino60:
Well as i understand the best way if you need to know something, is to test it, no one gave me the answer that i needed.

Because you did not ask the question in a way that made it clear what you asked, and because you did not give the information, needed to understand what you were doing.

Because you did not ask the question in a way that made it clear what you asked, and because you did not give the information, needed to understand what you were doing.

My question was realy clear and somethime if you know when you need to keep something secret you don't start type the full
story about what "you" are doing.

I gave you a +1 "karma" but i shouldn't.

Thanks for help, but i already got what i need from other forum.

OK, glad you solved it.

A hint: If you want to be secret, a forum with public access is maybe not the best place to do it.
Forums are about sharing information.

If you want "secret", you hire a consultant, and pay for her silence.