I´m testing USB Host MouseController example - working great ! But when adding some code like ADC read or pin control, that working only when moves mouse !!!!!
I tried it adding the Blink code and both worked OK. Here the code I tried.
/*
Mouse Controller Example
Shows the output of a USB Mouse connected to
the Native USB port on an Arduino Due Board.
created 8 Oct 2012
by Cristian Maglie
http://arduino.cc/en/Tutorial/MouseController
This sample code is part of the public domain.
*/
// Require mouse control library
#include <MouseController.h>
// Initialize USB Controller
USBHost usb;
int led = 13;
// Attach mouse controller to USB
MouseController mouse(usb);
// variables for mouse button states
boolean leftButton = false;
boolean middleButton = false;
boolean rightButton = false;
boolean left;
boolean middle;
boolean right;
// This function intercepts mouse movements
void mouseMoved() {
Serial.print("Move: ");
Serial.print(mouse.getXChange());
Serial.print(", ");
Serial.println(mouse.getYChange());
}
// This function intercepts mouse movements while a button is pressed
void mouseDragged() {
Serial.print("DRAG: ");
Serial.print(mouse.getXChange());
Serial.print(", ");
Serial.println(mouse.getYChange());
}
// This function intercepts mouse button press
void mousePressed() {
Serial.print("Pressed: ");
if (mouse.getButton(LEFT_BUTTON)){
Serial.print("L");
leftButton = true;
}
if (mouse.getButton(MIDDLE_BUTTON)){
Serial.print("M");
middleButton = true;
}
if (mouse.getButton(RIGHT_BUTTON)){
Serial.print("R");
Serial.println();
rightButton = true;
}
}
// This function intercepts mouse button release
void mouseReleased() {
Serial.print("Released: ");
if (!mouse.getButton(LEFT_BUTTON) && leftButton==true) {
Serial.print("L");
leftButton = false;
}
if (!mouse.getButton(MIDDLE_BUTTON) && middleButton==true) {
Serial.print("M");
middleButton = false;
}
if (!mouse.getButton(RIGHT_BUTTON) && rightButton==true) {
Serial.print("R");
rightButton = false;
}
Serial.println();
}
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
Serial.println("Program started");
delay(200);
}
void loop()
{
// Process USB tasks
usb.Task();
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000);
}
It could help also if you show us the code you ran that has the problem.
I´m testing your code but not working - same problem. Few first blink working - after few second stoped blinking. When mouse move again few second working.
Arduino IDE v1.5.1r2
WinXP SP3 and
Genius USB mouse Net Scroll 120
powering over USB programming port
I have my PC connected to the programming port (same drive) and my mouse to the Native port (Bossac driver).
I noticed that the LOW led status is taking a bit longer (around 2 sec) but still blinking.