keyboard emulation

Status
Not open for further replies.
Hi all.

I am a complete newby here and have the following question.
Can I use the Teensy LC to send keyboard emulation inputs to a windows pc using 20 push buttons in total, and if so, could I program each push button to emulate a particular key simulation. I hope I make sense.
I am in the process of building a pc based jukebox using DWjukebox as the software

Many thanks

Longplayer
 
Hi again.
Many thanks for your instant reply. I have looked at the link that you gave and it becomes clearer. Please excuse my lack of knowledge but when you talk about installation of Arduino + Teensyduino are you talking about just the software or do I need additional hardware as well as the Teensy LC.
 
Hi folks.
OK I think I have a handle on it now. As I said, I will need to set up a total of twenty push button inputs and from what you have explained, it looks fairly straight-foward. ( maybe! )
It may be a little while before I get to that stage of my project but I will keep you posted.
I see that you are in France. I live in the Perigord. who would you recommend as a supplier (France or UK)
 
Hi again. One other thing just came to mind. If I plug in a standard usb keyboard to carry out certain maintenance work to the jukebox software, would I have to disable the Teensy first, or will it sit happily in the background.

Thanks

Longplayer
 
I believe that it should work just fine... I am pretty sure I have configured Teensy to include Keyboard as one of its USB types and my system (USB) keyboard continued to work fine.
 
Hi all.
I am now getting to grips with the project. Got it all worked out on the software side of things. The problem I have is that I can not see exactly how many push buttons I can connect to the inputs on the Teensy LC These are simple two wire buttons, normally open and then close on push. Each button can be asigned to any keyboard key as my software (DW JUkebox allows for setting up keys.

Longplayer
 
If you follow the button example you can have as many buttons as you have input/output pins, 23 by adding more

Bounce buttonx = Bounce(x, 10);

pinMode(x, INPUT_PULLUP);

buttonx.update();

if (buttonx.fallingEdge()) {Keyboard.print("l");}

lines in the required places, where x is the pin numbers and l is the letter you want each button to trigger.

Though because pin 13 has an LED on it will be much easier if you stick with 22 total and skip 13. The buttons go between the pin and the gnd pin and it does not matter which way round they get wired so aim for simple and easy to fix in layout. Do make sure you don't get 5V on the inputs at any time or you will have a dead board.

This will get you a system where multiple keys will be actioned in turn. If this is not fast enough for you then you need to look at the micro manager way in the link above, but that gets complex quite quick so suggest a test build with the code as written and say 5 buttons to start with and build out from there.

If you need more buttons there are lots of ways to achieve that but all will add complexity so would suggest getting a working 22 button unit in service through several code upgrades first.
 
Last edited:
My project requires 22 buttons. I can set these to emulate any keypress as I have a control file within my program to allow me to match any key with any input for the jiukebox. I also have the normal key repeat function turned off in the Windows os.

Are you saying that I can use all of the Teensy Lc pins numbered 1 to 23 (except pin 13) to provide inputs from my push buttons or is it a bit more involved than that
I think the common ground is a separate pin (pin 0) so effectively I would be connecting each push button between ground and the individual numbered pin that it is connected to when I press that button.
Does all that sound right?

Longplayer
 
That's it. there are more complex ways to arrange things but for starting out one button per pin is easy to keep track of. The keyboard.print command will be sending just one instance of a keypress which is one advantage of doing it that way.

Gnd is the first pin as shown on the reference card, but not IO pin 0, don't mix those up when you start wiring. Do really suggest you only wire 4 or so pins when you start this thing, make sure it all makes sense and works. Fixing wiring on four pins is heaps easier than 22.
 
Hi GremlinWrangler.
Many thanks for your help. I have ordered my Teensy LC along with pins etc. but do not know when they will get here ( ordered in France ) I will post an update when I get started.
There was just one other small issue that occured to me. One component of my jukebox setup requires me to hold down a key (this key is not used for anything else in the program) and while holding it down I press a second key to select an interface within the program. I am using Eventghost software to make this happen so if this a problem with the programing of the Teensy, I can get round in Eventghost.

Many thanks

Longplayer
 
If you want a key to be held down you will need to use press and release as listed above and have your code track when to send the release. Bounce has a rising edge function as well so basic way is to just add another if to check for that on that key
 
You can also just use the read() method of the bounce library... Again assuming you are using the setup where you use the internal Pullup Resistors (INPUT_PULLUP) and connect the other side of switch to ground.
Then if after you call a buttons update method, you then do a read() and it returns 0 you know that, that button is pressed at the time. So you can then do things like:

After that you have a few different ways to code it. You could have whole section of code that you use to check the other buttons that can change the state... Or you could do it as you detect some other button changes to check the current state of the interface selection button... i.e. either something like:

Code:
void loop() {
    interface_select_button.update();   // make sure your interface buttons state is updated.
    if (interface_select_button.read() == 0) {
        // Check the N buttons that you wish to use to change the state.
    } else {
        // Check all of the buttons that normally check... 
    }
...

or something like: have an array of buttons...
Code:
void loop() {
    interface_select_button.update();   // make sure your interface buttons state is updated.
    for (uint8_t i = 0; i < COUNT_BUTTONS) {
       if (my_button[i].update()) {
           // button changed state
           if (my_button[i].fallingEdge() {
               // Button was just pressed.
               if (interface_select_button.read() == 0) {
                   // process the button when interface button is selected
               } else {
                   // process the button press when interface button is not selected
               }
            }
        }
    }
...
Again many different ways to do it...
 
Status
Not open for further replies.
Back
Top