We use teensy lc to emulate a keyboard.
We wrote a software in vb.net that hooks the keyboard to catch the key events on background.
The teensy is connected to a photocell to count people passages.
Recently in windows 10, after a random number of cicles, our software does not detect the teensy keyboard any more.
Do you have any suggestion?
The teensy code:
const int ledPin = 13;
const int buttonPin = 20;
const int debounceTime = 20; // // 10 ms debounce
int primoavvio = 0;
byte previousState = HIGH;
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (primoavvio == 0) {
blink();
}
byte buttonState = digitalRead(buttonPin);
if (buttonState != previousState){
if (buttonState == LOW) {
digitalWrite(ledPin, HIGH);
Keyboard.set_key1(KEY_F12);
Keyboard.send_now();
}
previousState = buttonState;
} else {
Keyboard.set_key1(0);
Keyboard.send_now();
Keyboard.releaseAll();
digitalWrite(ledPin, LOW);
}
delay(100);
}
void blink() {
primoavvio = 1;
digitalWrite(ledPin, HIGH); // set the LED on
delay(750); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(650); // wait for a second
digitalWrite(ledPin, HIGH); // set the LED on
delay(450); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(350); // wait for a second
digitalWrite(ledPin, HIGH); // set the LED on
delay(250); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(150); // wait for a second
digitalWrite(ledPin, HIGH); // set the LED on
delay(100); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(100); // wait for a second
digitalWrite(ledPin, HIGH); // set the LED on
delay(100); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
digitalWrite(ledPin, HIGH); // set the LED on
delay(100); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(100); // wait for a second
digitalWrite(ledPin, HIGH); // set the LED on
delay(100); // wait for a second
digitalWrite(ledPin, LOW);
Thanks
We wrote a software in vb.net that hooks the keyboard to catch the key events on background.
The teensy is connected to a photocell to count people passages.
Recently in windows 10, after a random number of cicles, our software does not detect the teensy keyboard any more.
Do you have any suggestion?
The teensy code:
const int ledPin = 13;
const int buttonPin = 20;
const int debounceTime = 20; // // 10 ms debounce
int primoavvio = 0;
byte previousState = HIGH;
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (primoavvio == 0) {
blink();
}
byte buttonState = digitalRead(buttonPin);
if (buttonState != previousState){
if (buttonState == LOW) {
digitalWrite(ledPin, HIGH);
Keyboard.set_key1(KEY_F12);
Keyboard.send_now();
}
previousState = buttonState;
} else {
Keyboard.set_key1(0);
Keyboard.send_now();
Keyboard.releaseAll();
digitalWrite(ledPin, LOW);
}
delay(100);
}
void blink() {
primoavvio = 1;
digitalWrite(ledPin, HIGH); // set the LED on
delay(750); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(650); // wait for a second
digitalWrite(ledPin, HIGH); // set the LED on
delay(450); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(350); // wait for a second
digitalWrite(ledPin, HIGH); // set the LED on
delay(250); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(150); // wait for a second
digitalWrite(ledPin, HIGH); // set the LED on
delay(100); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(100); // wait for a second
digitalWrite(ledPin, HIGH); // set the LED on
delay(100); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
digitalWrite(ledPin, HIGH); // set the LED on
delay(100); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(100); // wait for a second
digitalWrite(ledPin, HIGH); // set the LED on
delay(100); // wait for a second
digitalWrite(ledPin, LOW);
Thanks