Arduino Forum

Using Arduino => Project Guidance => Topic started by: TheAaronTF on Apr 06, 2016, 11:51 pm

Title: IR LED Keyboard
Post by: TheAaronTF on Apr 06, 2016, 11:51 pm
Hello all,

I am looking to program an Arduino Uno to control an infrared LED keyboard.
The short story: I have a six-by-six grid of LEDs and receivers. There are twelve LEDs and twelve receivers, six on each side of the keyboard.
I have assembled the keyboard, and now need to look into wiring and programming. I understand enough of the basics of the programming that all I need is some guidance.
To begin, I should be able to use digital pins 2-13 as inputs for the receivers, while using the 5.5V out to power both the LEDs and receivers.
Would there be any problems with current?
Also, in terms of the code, is there any way to initialize multiple pins as inputs, rather than do each one individually?

I apologize if I am using the wrong terminology, and please let me know if I need to supply more information.

Thank you for your help. 
Title: Re: IR LED Keyboard
Post by: OldSteve on Apr 07, 2016, 03:13 am
Hello all,
I am looking to program an Arduino Uno to control an infrared LED keyboard.
The short story: I have a six-by-six grid of LEDs and receivers. There are twelve LEDs and twelve receivers, six on each side of the keyboard.
I have assembled the keyboard, and now need to look into wiring and programming. I understand enough of the basics of the programming that all I need is some guidance.
To begin, I should be able to use digital pins 2-13 as inputs for the receivers, while using the 5.5V out to power both the LEDs and receivers.
Would there be any problems with current?
Before we address any of this, we need more information.
What is the layout of the LEDs and receivers?
How much current will each LED consume?
What type of IR receiver are you using?
How will you differentiate a 'keypress' from a hovering finger?

This bit's easy enough:-
Quote
Also, in terms of the code, is there any way to initialize multiple pins as inputs, rather than do each one individually?
Code: [Select]
for(int i=2;i <= 13;i++)
    pinMode(i, INPUT);  // Or INPUT_PULLUP - whichever you need.
Title: Re: IR LED Keyboard
Post by: TheAaronTF on Apr 07, 2016, 09:49 pm
Before we address any of this, we need more information.
What is the layout of the LEDs and receivers?
How much current will each LED consume?
What type of IR receiver are you using?
How will you differentiate a 'keypress' from a hovering finger?
The LEDs will be laid out along the perimeter of the keyboard, LEDs facing receivers.
The attached image is the actual SolidWORKS drawing and was used to cut the parts out of acrylic. The green lines point to there the LEDs will go, while the orange show where the receivers will go.
Each LED will consume 100mA of current. (See here (http://www.digikey.com/product-search/en?keywords=751-1203-ND)).
Each receiver will consume 0.7mA of current. (See here (http://www.digikey.com/product-search/en?keywords=TSOP4838-ND))
I have not yet worried about differentiating keystrokes from hovering fingers, as I think this may be beyond the function of the keyboard.

Thank you again for your help. 
Title: Re: IR LED Keyboard
Post by: Grumpy_Mike on Apr 07, 2016, 10:48 pm
Sounds like this old pre Arduino project of mine
http://www.thebox.myzen.co.uk/Hardware/The_Sound_Square.html (http://www.thebox.myzen.co.uk/Hardware/The_Sound_Square.html)
Title: Re: IR LED Keyboard
Post by: OldSteve on Apr 08, 2016, 01:12 am
Here's the pic, so everyone can see it easily:-
(http://forum.arduino.cc/index.php?action=dlattach;topic=392048.0;attach=162229)

You're aware that the IR LEDs must all be driven with a modulated 38kHz signal, I assume? It can't even be a continuous 38kHz - there's a maximum burst length that the receivers can detect. Any longer and the output returns high, (inactive). (I use TSOP4838 receivers myself.)


Quote
I have not yet worried about differentiating keystrokes from hovering fingers, as I think this may be beyond the function of the keyboard.
It is beyond it's function. Maybe it is time to worry about it. Your keyboard will not work if you can't sort out this problem.

I've attached the TSOP4838 datasheet, in case you don't already have it. (You probably do, but it does no harm to be sure.)

Title: Re: IR LED Keyboard
Post by: TheAaronTF on Apr 08, 2016, 07:42 am
You're aware that the IR LEDs must all be driven with a modulated 38kHz signal, I assume? It can't even be a continuous 38kHz - there's a maximum burst length that the receivers can detect. Any longer and the output returns high, (inactive). (I use TSOP4838 receivers myself.)

It is beyond it's function. Maybe it is time to worry about it. Your keyboard will not work if you can't sort out this problem.

I've attached the TSOP4838 datasheet, in case you don't already have it. (You probably do, but it does no harm to be sure.)


I'm not aware of that, nor do I understand what that means. As I said, I have very little understanding of all the intricate technicalities of running something like this.
So assume I don't know much.
Also, understand that this does not have to be entirely functional. At this point, it is going to be a proof-of-concept prototype. I just need to be able to show that this is possible with the equipment I have.
Title: Re: IR LED Keyboard
Post by: OldSteve on Apr 08, 2016, 08:17 am
I'm not aware of that, nor do I understand what that means.
The receivers are tuned to only detect IR at 38kHz, and to reject continuous IR. In a remote control, a 38kHz carrier is used, then that's modulated, (quickly turned on and off), to generate an output that is pulsed according to the digital bits that are being sent. Then, because you want to drive the IR LEDs with a current of 100mA, you need to use a suitable driver for each, a transistor, MOSFET or multi-channel driver chips like ULN2003, ULN2803 etc.

The next point is that the IR LEDs are wide-angle and not a tight beam, so moving your finger towards a given key will not necessarily be recognisable as that key. You could consider laser rather than IR LEDs maybe, if it weren't for the point I mentioned earlier - even if you did get that aspect working, how does your system differentiate a valid keypress from a finger just above the key?
 

Quote
Also, understand that this does not have to be entirely functional. At this point, it is going to be a proof-of-concept prototype. I just need to be able to show that this is possible with the equipment I have.
I'm afraid that under the circumstances, you have the exact opposite situation. It's not possible with the equipment that you have.
Title: Re: IR LED Keyboard
Post by: Grumpy_Mike on Apr 08, 2016, 08:56 am
At this point, it is going to be a proof-of-concept prototype. I just need to be able to show that this is possible with the equipment I have.
Did you look at my project? That did not use modulated IR but the emitters and sensors were down tubes to narrow the angle. Also the emitter and sensor were alternated along each side to isolate them a bit more. Finally strong light did interfere with it.
Also note that you can not press two keys at once because that turns into four beam crossings.

For a keyboard it would not work so consider your concept not proven.
Title: Re: IR LED Keyboard
Post by: TheAaronTF on Apr 11, 2016, 08:13 pm
The receivers are tuned to only detect IR at 38kHz, and to reject continuous IR. In a remote control, a 38kHz carrier is used, then that's modulated, (quickly turned on and off), to generate an output that is pulsed according to the digital bits that are being sent. Then, because you want to drive the IR LEDs with a current of 100mA, you need to use a suitable driver for each, a transistor, MOSFET or multi-channel driver chips like ULN2003, ULN2803 etc.

The next point is that the IR LEDs are wide-angle and not a tight beam, so moving your finger towards a given key will not necessarily be recognisable as that key. You could consider laser rather than IR LEDs maybe, if it weren't for the point I mentioned earlier - even if you did get that aspect working, how does your system differentiate a valid keypress from a finger just above the key?
 
I'm afraid that under the circumstances, you have the exact opposite situation. It's not possible with the equipment that you have.
I do have access to a ULN chip. I'm not yet sure of the exact model, but it is something close to the ULN2003/ULN2002.
I believe I can remedy the angle problem one way or another.