Go Down

Topic: DUE and windows problems (Read 3 times) previous topic - next topic

razer93

hi guys, i'm playing with mouse/keyboard emulation on the DUE board (native usb of course), i noticed that those sketches doens't work on my windows7 32bit machine :(
on mac all just works good, on windows it recognise me the device as "Arduino Due" with this id: USB\VID_2341&PID_003E&REV_0100

even installing drivers nothing changes... doesn't work!!
any clue?
thanks

cmaglie

I see that Windows is very slow to enumerate USB devices (it takes 3 or 4 seconds at least) while linux and mac are a snap.

Try to add a delay(5000) before Keyboard.begin().

C
C.

razer93

nothing to do... someone with windows? or same problem? other solutions?

cmaglie

May you post your sketch? I'll try on my PC, maybe I can reproduce the bug...

C
C.

razer93

i'm using exactly the example included in the IDE 1.5
Code: [Select]
const int upButton = 2;     
const int downButton = 3;       
const int leftButton = 4;
const int rightButton = 5;
const int mouseButton = 6;

int range = 5;              // output range of X or Y movement; affects movement speed
int responseDelay = 10;     // response delay of the mouse, in ms


void setup() {
  // initialize the buttons' inputs:
  pinMode(upButton, INPUT);       
  pinMode(downButton, INPUT);       
  pinMode(leftButton, INPUT);       
  pinMode(rightButton, INPUT);       
  pinMode(mouseButton, INPUT);
  // initialize mouse control:
  Mouse.begin();
}

void loop() {
  // read the buttons:
  int upState = digitalRead(upButton);
  int downState = digitalRead(downButton);
  int rightState = digitalRead(rightButton);
  int leftState = digitalRead(leftButton);
  int clickState = digitalRead(mouseButton);

  // calculate the movement distance based on the button states:
  int  xDistance = (leftState - rightState)*range;
  int  yDistance = (upState - downState)*range;

  // if X or Y is non-zero, move:
  if ((xDistance != 0) || (yDistance != 0)) {
    Mouse.move(xDistance, yDistance, 0);
  }

  // if the mouse button is pressed:
  if (clickState == HIGH) {
    // if the mouse is not pressed, press it:
    if (!Mouse.isPressed(MOUSE_LEFT)) {
      Mouse.press(MOUSE_LEFT);
    }
  }
  // else the mouse button is not pressed:
  else {
    // if the mouse is pressed, release it:
    if (Mouse.isPressed(MOUSE_LEFT)) {
      Mouse.release(MOUSE_LEFT);
    }
  }

  // a delay so the mouse doesn't move too fast:
  delay(responseDelay);
}

Go Up