TelephoneBill
Well-known member
I would like to test the USB Host feature of my T3.6 board but I have run into trouble. Any assistance would be appreciated.
I'm using the "Mouse.ino" sketch (code below) from "wwatson" found in the zip file at https://forum.pjrc.com/threads/45740-USB-Host-Mouse-Driver (post #3). This compiled and downloaded OK without any added files being included in the IDE (using Arduino 1.8.4 and Teensyduino 1.40). I get the "USB Host Mouse Testing" signon message, but when I move the mouse around I don't get any more serial text printed. Nothing from button presses or scroll wheel. The mouse LED itself is illuminated. Its a Logitech M90. The code is looping - tested with a Serial.println("Hello") and Delay(1000) diagnostic lines added to the loop - but the "mouse1.available()" line appears never to go "true".
My config... I have soldered 4 pins to the USB Host position on the board and connected a USB internal cable - Red pin 1 (5v), White pin2 (D-), Green pin3 (D+), Black pin4 (GND) - pin5 not connected. M90 plugged into USB socket A. I have downloaded the code to the board and measured +5 volts across USB Host pin1/pin4. I have looked at the signals (wrt GND) on pin2 and pin3 and get some strange "one shot" pictures. The D- signal (pin 2) is shown on the left below, and the D+ (pin3) on the right. The D- signal is continuous, but the D+ signal is only seen on reset.
I tried another mouse but got exactly the same result.
I'm using the "Mouse.ino" sketch (code below) from "wwatson" found in the zip file at https://forum.pjrc.com/threads/45740-USB-Host-Mouse-Driver (post #3). This compiled and downloaded OK without any added files being included in the IDE (using Arduino 1.8.4 and Teensyduino 1.40). I get the "USB Host Mouse Testing" signon message, but when I move the mouse around I don't get any more serial text printed. Nothing from button presses or scroll wheel. The mouse LED itself is illuminated. Its a Logitech M90. The code is looping - tested with a Serial.println("Hello") and Delay(1000) diagnostic lines added to the loop - but the "mouse1.available()" line appears never to go "true".
My config... I have soldered 4 pins to the USB Host position on the board and connected a USB internal cable - Red pin 1 (5v), White pin2 (D-), Green pin3 (D+), Black pin4 (GND) - pin5 not connected. M90 plugged into USB socket A. I have downloaded the code to the board and measured +5 volts across USB Host pin1/pin4. I have looked at the signals (wrt GND) on pin2 and pin3 and get some strange "one shot" pictures. The D- signal (pin 2) is shown on the left below, and the D+ (pin3) on the right. The D- signal is continuous, but the D+ signal is only seen on reset.
I tried another mouse but got exactly the same result.
Code:
// Simple test of USB Host Mouse/Keyboard
//
// This example is in the public domain
#include "USBHost_t36.h"
USBHost myusb;
USBHub hub1(myusb);
USBHub hub2(myusb);
USBHub hub3(myusb);
KeyboardController keyboard1(myusb);
KeyboardController keyboard2(myusb);
MouseController mouse1(myusb);
void setup()
{
while (!Serial) ; // wait for Arduino Serial Monitor
Serial.println("USB Host Testing");
myusb.begin();
keyboard1.attachPress(OnPress);
keyboard2.attachPress(OnPress);
}
void loop()
{
myusb.Task();
Serial.println("Hello");
delay(1000);
if(mouse1.available()) {
Serial.print("buttons = ");
Serial.print(mouse1.getButtons(),DEC);
Serial.print(", wheel = ");
Serial.print(mouse1.getWheel(),DEC);
Serial.print(", mouseX = ");
Serial.print(mouse1.getMouseX(),DEC);
Serial.print(", mouseY = ");
Serial.println(mouse1.getMouseY(),DEC);
mouse1.mouseDataClear();
}
delay(50);
}
void OnPress(int key)
{
Serial.print("key '");
Serial.print((char)key);
Serial.print("' ");
Serial.println(key);
//Serial.print("key ");
//Serial.print((char)keyboard1.getKey());
//Serial.print(" ");
//Serial.print((char)keyboard2.getKey());
//Serial.println();
}