Go Down

Topic: How to read a USB joystick plugged into the native USB port? (Read 1 time) previous topic - next topic

waverider57

Hi, I'm new to Arduino programming, but I'm having trouble reading from the USB native port on my Arduino DUE board.

I have a Cyborg PC Flight Stick v1 usb joystick connected to the native USB port on my DUE and I cannot detect any input from the joystick.

The program is as follows:
Code: [Select]

void setup() {
  // initialize serial:
  Serial.begin(9600);
  SerialUSB.begin(9600);
}

void loop() {
  // if there's any serial available, read it:
  while (SerialUSB.available() > 0) {
    Serial.println(SerialUSB.read());
    }
}



I can't seem to find any info on the SerialUSB class.
What am I doing wrong?  Any help would be appreciated! 

AlfredJingle

#1
Jun 28, 2013, 12:43 am Last Edit: Jun 28, 2013, 12:46 am by AlfredJingle Reason: 1
You need to have a library for reading data from a USB joystick with your Arduino. For instance you could try

http://airspayce.com/mikem/arduino/USBJoystick.


waverider57

Hey Alfred,
Thank-you for your suggestion.  I will definitely give that a try. 


rabinath

I am trying the same thing. I made it work about 10 minutes ago by "porting" parts of the USB Host Shield 2 stack. It's basically renaming "USB" class usages into USBHost as well as renaming quite a few uint8_t into uint32_t in the virtual methods.

I will do a clean port of it again and wrap it up as a library. If time allows I'll also write a short readme on how to port host shield stack drivers to the Due.

cmaglie

@rabinath,

can you publish your code, even if its not yet finished?

C
C.


Go Up