Question about Arduino Keyboard library and USB sleeping

Status
Not open for further replies.

johnny

New member
Hi there!

I'm using Teensy 2.0 w/ the Arduino Keyboard/Mouse library. I've noticed that after the computer goes to sleep, even after I wake it up again, my Teensy device will not send `Keyboard.press` (or Mouse) commands, even though it is clearly responding to inputs (it blinks LEDs as expected). (Caveat here is that it may have nothing to do with sleep -- could just be a long period of inactivity)

Do I need to be handling the computer going to sleep? Does the computer going to sleep require a new `Keyboard.begin` or something? How do I detect the computer sleeping? I've read a lot about getting the Teensy to wake a computer from sleep but I can't find anything about detecting it happening.

Here's the code:

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

int redPin = 14;
int bluePin = 15;
int footswitchPin1 = 20;
int footswitchPin2 = 13;

void setup() {
  pinMode(redPin, OUTPUT);
  pinMode(bluePin, OUTPUT);

  pinMode(footswitchPin1, INPUT_PULLUP);
  pinMode(footswitchPin2, INPUT_PULLUP);
}

void loop() {
  digitalWrite(redPin, LOW);
  digitalWrite(bluePin, LOW);

  if (digitalRead(footswitchPin1) == LOW) {
    Mouse.move(0,0,5);
    digitalWrite(redPin, HIGH);
  }

  if (digitalRead(footswitchPin2) == LOW) {
    Mouse.move(0,0,-5);
    digitalWrite(bluePin, HIGH);    
  }

  delay(250);
}

The wiring is super simple. I've got two momentary switches wired to pins 20 and 13 and LEDs wired to pins 14 and 15.

Thanks for any help, this is my first Teensy project, if you couldn't tell. ;)
 
Ah sorry, yes I'm running Windows 10.

I can definitely update my Windows 10 settings but I don't have this issue with other peripherals. Are those somehow able to detect the suspend and reconnect?

Thanks for the response!
 
Status
Not open for further replies.
Back
Top