Teensy 2.0 pushbutton not working on different computer

Status
Not open for further replies.

numz

Member
Hello! I am trying to use the Teensy 2.0 board to act as a keyboard and tab through 8 times and output a sentence when pushbutton is pressed. Everything works on my laptop. However, when I tried to connect it to a desktop computer with Windows 7. It did update the drivers and show up as a keyboard, however, when I press the push button it does nothing. When I tried to press the button on the board, it resets then the "HID keyboard" option in device manager goes away. If anyone can help me with this that'll be great, thanks!

Also FYI, I am very new to this so please bear with me if things don't make sense.
 
Perhaps trying one of the simpler USB Keyboard examples would show desired function. It may be some timing issue when it comes to the Windows 7 machine with the sketch as written?

If a simple sample works it might provide a way forward, if not then showing the code with the button activation and a simple send might allow diagnosing any issue.
 
Thank you for the reply, this is the code I'm currently using:

Code:
#include <Bounce.h>
#include <Keyboard.h>


Bounce button7 = Bounce(7, 10);  // 10 = 10 ms debounce time

void setup() {
 
  delay(2000);
  
  pinMode(7,INPUT);

   button7.update();
   
     if (button7.fallingEdge()) {
    Keyboard.println("B7 not press");
  }

    if (button7.risingEdge()) {
      
            for (int x = 0; x < 8; x++) {
            Keyboard.press(KEY_TAB);
            Keyboard.release(KEY_TAB);
      }
      
    Keyboard.println("Cerner keyboard tab test");  
  }

}

void loop() {

  
}

It seems simple right? Or should I reduce it down even more. I think you are right with the timing issue, because as soon as I press the programming button the "HID keyboard" from device manager disappears. Also whenever I press the pushbutton, the program does not run until I press the programmable button on the board again, do you think that might be the issue? I think I am missing something from my code.
From what I know the 'victim computer' do not need any additional drivers to be installed at all, and it does show up as keyboard as well. Just does not run the file as it runs on me personal laptop I guess which is the main issue.
 
Last edited by a moderator:
Just a glance - not a Teensy 2 user or much with USB Keyboard …

All that code is ONE time in setup()

It falls through only once - after the initial delay(2000) there are no waits or while() or logic to wait for the device to connect for sure?

Also as far as timing the for loop for the TAB press/release is done without any delay() pauses between those 16 key press and release commands.
 
Thank you for getting back. Yup I put it in the setup loop for more control.

The thing is, I'm only pressing the push button after the windows 7 desktop computer detects that a keyboard is connected (aka the teensy). So the delay won't really help much.

However, the problem is: to have the pushbutton output to what I want to do, I have to press the program button on the board before I press the pushbutton. And that causes the keyboard in device manager to go away. That is what I can't figure out how to code, to not have to press the program button before the pushbutton. Is that making sense at all?
 
Setup runs only once about 400 ms after the Teensy is plugged in.

Other than the delay nothing stops the code from immediately executing and being done immediately after that. There is no wait for the button to be pressed in the code shown.

Any press of the Program Button on the Teensy takes it offline as 'USB Keyboard' to program mode. If the Teensy Loader is present it will be programmed and restarted into setup() where Windows will see the keyboard arrive, deliver 16 key commands and quit after a 2 second delay.

The program output isn't provided so it isn't known what appears on the Serial Monitor.

Make this line the last line of setup() and it may show something about how it is working: Keyboard.println("DONE!");
 
Hi Defragster! You were right the issue was putting it into the setup. Also found out that there's just a long wait time for the drivers to be setup but eventually it does show up as a keyboard so it worked out!

I actually have a follow-up question. Would you by any chance know how to send these same commands over wify? Maybe any other board suggestion that I can use besides the Teensy (I was thinking raspberry pie and the micropython wipy board) that can do the same task but over wifi. Is that even makes sense?
 
Glad it worked out.

As far as the follow-up. Not clear how WiFi would fit in and what the use case is? Unless you want remote control of something on USB as a keyboard - controlled by second device on WiFi?
 
Thank you for the reply.

So I am trying to integrate a medical device with an EHR (Electronic Health Record), however, before we go on to buying an actual page on the record which costs thousands of dollars I want to test and see if it actually works. Since we only need to input one value after a few tabs on the EHR page, I thought to make a programmable keyboard that the EHR computer takes input from without any protocols to integrate as it thinks of it as a keyboard. After testing out that the Teensy with a direct USB connection works, I wanted to move on to doing the same through wifi as the actual code of the medical device is all though the micropython wipy board. Does that help at all?
 
Also found out that there's just a long wait time for the drivers to be setup but eventually it does show up as a keyboard so it worked out!

Microsoft fixed that long wait in Windows 10.

It isn't anything happening in Teensy. The long wait is simply a bug (or "feature") in older versions of Windows.
 
Status
Not open for further replies.
Back
Top