Pages: [1]   Go Down
Author Topic: usb keyboard hardware  (Read 689 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So im trying to emulate a usb keyboard and i was just wondering, is it valid to just cute a USB cable and plug it into a breadboard then into the arduino or do i need resistors and such to make it work? Thanks.
Logged

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 33
Posts: 1906
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
To be clear, do you want to use Arduino to connect to a USB cable and appear to be a USB keyboard to a desktop computer etc??

If so, there's a lot more to this than connections..  Google "arduino emulate USB keyboard" and you'll start to get an idea of what is involved...

Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
To be clear, do you want to use Arduino to connect to a USB cable and appear to be a USB keyboard to a desktop computer etc??

If so, there's a lot more to this than connections..  Google "arduino emulate USB keyboard" and you'll start to get an idea of what is involved...



I have done so and i have the software all done, just working on the hardware part now. just wanted to know if i need to use anything other then a usb cable, breadboard, and my arduino for just a little hello world.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 205
Posts: 12844
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Teensy; no extra hardware necessary...
http://pjrc.com/teensy/td_keyboard.html
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok i have the right hardware built i think and im using the example that comes with the lib from here:
http://code.google.com/p/vusb-for-arduino/
code:
Code:
#include "UsbKeyboard.h"

#define BUTTON_PIN 12

// If the timer isr is corrected
// to not take so long change this to 0.
#define BYPASS_TIMER_ISR 1

void setup() {
  pinMode(BUTTON_PIN, INPUT);
  digitalWrite(BUTTON_PIN, HIGH);
 
#if BYPASS_TIMER_ISR
  // disable timer 0 overflow interrupt (used for millis)
  TIMSK0&=!(1<<TOIE0); // ++
#endif
}

#if BYPASS_TIMER_ISR
void delayMs(unsigned int ms) {
   /*
  */
  for (int i = 0; i < ms; i++) {
    delayMicroseconds(1000);
  }
}
#endif

void loop() {
 
  UsbKeyboard.update();

  digitalWrite(13, !digitalRead(13));

  if (digitalRead(BUTTON_PIN) == 0) {
   
    //UsbKeyboard.sendKeyStroke(KEY_B, MOD_GUI_LEFT);
   
    UsbKeyboard.sendKeyStroke(KEY_H);
    UsbKeyboard.sendKeyStroke(KEY_E);
    UsbKeyboard.sendKeyStroke(KEY_L);
    UsbKeyboard.sendKeyStroke(KEY_L);
    UsbKeyboard.sendKeyStroke(KEY_O);

    UsbKeyboard.sendKeyStroke(KEY_SPACE);

    UsbKeyboard.sendKeyStroke(KEY_W);
    UsbKeyboard.sendKeyStroke(KEY_O);
    UsbKeyboard.sendKeyStroke(KEY_R);
    UsbKeyboard.sendKeyStroke(KEY_L);
    UsbKeyboard.sendKeyStroke(KEY_D);
    //UsbKeyboard.sendKeyStroke(KEY_B, MOD_GUI_LEFT);

    UsbKeyboard.sendKeyStroke(KEY_ENTER);
#if BYPASS_TIMER_ISR  // check if timer isr fixed.
    delayMs(20);
#else
    delay(20);
#endif
   
   }

}

My set up is like so
DIO2 - green wire
DIO4 - white
DIO5 - white
GRN - grn
5v - 5v
DIO12 - button

i get this in syslog:
Code:
Oct  3 21:50:03 emada-laptop kernel: [14576.550470] usb 2-1: new full speed USB device using ohci_hcd and address 38
Oct  3 21:50:03 emada-laptop kernel: [14576.732589] usb 2-1: device descriptor read/64, error -62
Oct  3 21:50:03 emada-laptop kernel: [14577.020127] usb 2-1: device descriptor read/64, error -62
Oct  3 21:50:04 emada-laptop kernel: [14577.312322] usb 2-1: new full speed USB device using ohci_hcd and address 39
Oct  3 21:50:04 emada-laptop kernel: [14577.497535] usb 2-1: device descriptor read/64, error -62
Oct  3 21:50:04 emada-laptop kernel: [14577.782600] usb 2-1: device descriptor read/64, error -62
Oct  3 21:50:04 emada-laptop kernel: [14578.070204] usb 2-1: new full speed USB device using ohci_hcd and address 40
Oct  3 21:50:05 emada-laptop kernel: [14578.492592] usb 2-1: device not accepting address 40, error -62
Oct  3 21:50:05 emada-laptop kernel: [14578.670124] usb 2-1: new full speed USB device using ohci_hcd and address 41
Oct  3 21:50:05 emada-laptop kernel: [14579.092576] usb 2-1: device not accepting address 41, error -62
Oct  3 21:50:05 emada-laptop kernel: [14579.092657] hub 2-0:1.0: unable to enumerate USB device on port 1

attached is also i picture of the set up. anyone have any idea what im doing wrong?


* download.jpg (68.79 KB, 638x854 - viewed 13 times.)
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm also busy with the Virtual USB keyboard. I have just got mine working. It wasn't easy. First I used a breadboard. That did not work. The pc did not recognise the Arduino as USB-device. USB is very sensative to tiny disruptions. Thats why the breadboard version doesn't work. After I soldered all to the proto-shield it did work and the Arduino is recognised as USB-keyboard. However it is still sensative. See the topic "Virtual USB Keyboard problem" for more info.

I do not understand the bypass timer part in your loop. I is not used in the code at http://www.practicalarduino.com/projects/virtual-usb-keyboard.
« Last Edit: October 30, 2011, 06:04:37 am by Jaaptina » Logged

Upstate NY
Offline Offline
Full Member
***
Karma: 2
Posts: 184
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't see how the ground on the breadboard is connected to the ground of the Arduino board.
Logged

Pages: [1]   Go Up
Jump to: