Conectar um teclado USB ao Arduino usando a Biblioteca PS2Keyboard (http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html)
Video Youtube: https://www.youtube.com/watch?v=xOinlGYvylU
Ligar o D- ao pino 2 do Arduino (DataPin)
Ligar o D+ ao pino 3 do Arduino (IRQPin)
Download Biblioteca: http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
Codigo de teste abaixo:
/* PS2Keyboard library example
PS2Keyboard now requries both pins specified for begin()
keyboard.begin(data_pin, irq_pin);
Valid irq pins:
Arduino Uno: 2, 3
Arduino Due: All pins, except 13 (LED)
Arduino Mega: 2, 3, 18, 19, 20, 21
Teensy 2.0: All pins, except 13 (LED)
Teensy 2.0: 5, 6, 7, 8
Teensy 1.0: 0, 1, 2, 3, 4, 6, 7, 16
Teensy++ 2.0: 0, 1, 2, 3, 18, 19, 36, 37
Teensy++ 1.0: 0, 1, 2, 3, 18, 19, 36, 37
Sanguino: 2, 10, 11
for more information you can read the original wiki in arduino.cc
at http://www.arduino.cc/playground/Main/PS2Keyboard
or http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
Like the Original library and example this is under LGPL license.
Modified by Cuninganreset@gmail.com on 2010-03-22
Modified by Paul Stoffregen <paul@pjrc.com> June 2010
*/
#include span style="color: #cc6600;">PS2Keyboard.h>
const int DataPin = 2;
const int IRQpin = 3;
PS2Keyboard keyboard;
void setup() {
delay(1000);
keyboard.begin(DataPin, IRQpin);
Serial.begin(9600);
Serial.println("Keyboard Test:");
}
void loop() {
if (keyboard.available()) {
// read the next key
char c = keyboard.read();
// check for some of the special keys
if (c == PS2_ENTER) {
Serial.println();
}
else if (c == PS2_TAB) {
Serial.print("[Tab]");
}
else if (c == PS2_ESC) {
Serial.print("[ESC]");
}
else if (c == PS2_PAGEDOWN) {
Serial.print("[PgDn]");
}
else if (c == PS2_PAGEUP) {
Serial.print("[PgUp]");
}
else if (c == PS2_LEFTARROW) {
Serial.print("[Left]");
}
else if (c == PS2_RIGHTARROW) {
Serial.print("[Right]");
}
else if (c == PS2_UPARROW) {
Serial.print("[Up]");
}
else if (c == PS2_DOWNARROW) {
Serial.print("[Down]");
}
else if (c == PS2_DELETE) {
Serial.print("[Del]");
}
else {
// otherwise, just print all normal characters
Serial.print(c);
}
}
}
Tags:
Olá,
Isso é exatamente o que estou precisando, seu vídeo não está mais disponível, mas tentei fazer utilizando um Arduino Nano.
Encontrei algo parecido no youtube: (1) How to Connect a USB Keyboard With an Arduino? - YouTube
Mas não consigo fazer funcionar, o projeto na verdade é para ser utilizado como Leitor de QrCode, mas tentei também com um teclado USB e ele simplesmente nem liga... abri o teclado e passei o multímetro, está recebendo 5v e GND normalmente, mas teclado nem da sinal de vida... a diferença do vídeo é que não tenho os resistores de 10k e estou procurando para ver se resolve o problema... mas acho improvável visto que o teclado nem liga.
Tentei uma ligação direta como você fez, mas também não chega nem a ligar.
O leitor: https://content.etilize.com/User-Manual/1061378985.pdf
Alguma sugestão?
Bem-vindo a
Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)
© 2024 Criado por Marcelo Rodrigues. Ativado por