Hello,
I am attempting to connect a mouse to my Arduino Uno by using the usb host shield. Basically i have the arduino shield connected to the uno, and then i have connected the mouse to the shield.
I have downloaded and installed the library for it, USB_Host_Shield_Library_2.
I am attempting one of the examples that should read input from by mouse and display it on the serial monitor, but all I am receiving is a bunch of junk data.
I have checked everywhere for how to actually use the libraries and haven't been able to find anything that I was able to understand.
Below shows the code. Any help is appreciated!
include
#include // Satisfy the IDE, which needs to see the include statment in the ino too. #ifdef dobogusinclude #include #endif #include class MouseRptParser : public MouseReportParser { protected: void OnMouseMove (MOUSEINFO *mi); void OnLeftButtonUp (MOUSEINFO *mi); void OnLeftButtonDown (MOUSEINFO *mi); void OnRightButtonUp (MOUSEINFO *mi); void OnRightButton Down (MOUSEINFO *mi); void OnMiddleButtonUp (MOUSEINFO *mi); void OnMiddleButtonDown (MOUSEINFO *mi); }; void MouseRptParser:: OnMouseMove (MOUSEINFO *mi) { Serial.print("dx="); Serial.print(mi->dX, DEC); Serial.print(" dy="); Serial.println(mi->dY, DEC); }; void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi) { Serial.println("L Butt Up"); }; void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi) { Serial.println("L Butt Dn"); }; void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi) { Serial.println("R Butt Up"); }; void MouseRptParser::OnRightButton Down (MOUSEINFO *mi) { Serial.println("R Butt Dn"); }; void Mouse ptParser::OnMiddleButtonUp (MOUSEINFO *mi) { Serial.println("M Butt Up"); }; void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi) { void Mouse ptParser::OnMiddleButtonDown (MOUSEINFO *mi) Serial.println("M Butt Dn"); }; USB Usb; USBHub Hub (&Usb); HIDBOOT USB_HID_PROTOCOL_MOUSE HidMouse (&Usb); MouseRptParser Prs; void setup() { Serial.begin( 115200); #if !defined (_MIPSEL_) while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CD Fendif Serial.println("Start"); == if (Usb.Init() -1) Serial.println("OSC did not start."); delay( 200 ); HidMouse. SetReportParser(0, Prs); } void loop() { Usb.Task(); } 055/3550DSOSOIJA 55CASIOOSIISSASASSZOSOSOIODAZSOOISE8D5OS5SSAS A5SIOSOSSOS ZS587555555 appp-555555555HS'S 'SISUSTST545154545454554355 Y5 NASSI-A--50505039595x5'5'5x555T5U) '-')) SIISSOSSSSSSno$0203Z5205555 850555ISSSS TSSSOTS5555555SSSSSSSS assajossz SOSOSCOSSSSSSSCOS4H00-SSO/003C0hEPSssISSCHOWCSSSSSSSSSSSSSSSSSSSOS050505050505050505050505050505 SOSSE3592355080050Z030555 Sepsoss.003521qejqesSsSSOISS003552350888300003001555355888015OSZIS-I5505505X35505523 SS550502303SSISSSNSX38555055555500 X350505055 55500000XSSOT 23585000000000000 Pozoss SZVS3555503308DOT VO 0 $ BOOXOOR 0525SSAZSSSBAZO 355005585430535020055231050513305053, 358503035zioso 055 Z N OXO 8 : COCOZSSSSOOOXF58155 OSO 0852s 5750310555507 8032555 35550385 SS 20 0005 G23755500373550333055503EEscoja 005 0 555 2 33 8050305, 30530335030005 SISZO0SS000500SOSSWZSSZS 5030035522505 50550703303055803550*23052353503035050552055+ 0525235039035COSYS505#STEMOSSSC, OWSZS3S5OS5I503550855.3750=03355 232X339595:15 CO3355 OGDOSOXS500,00155550MS IISSOOSI5505035 son DO SSOSCOSS 550550 MOSXO88=OZSON 000SSSOOOOZSCO0000008886- 00 00050SOZZ500000008888-- 000SSSSOOZ SVO 00008 8800I5SOSS 15\59''*''**'OSOSOS....OSSISTSTESSI ASUCIOSOCOS $5) S5012955TO0S00SV50000}ss=+5955) ss) 355 (+x35TSSSSS (550s) SSTSTOAS$35=19525+050$OSOSAOSTSSSEISASA5053002035003200355 000 0035555x320050550S0S0S07505515480STSSD440\100433NASS00S0SUNS5555+015SHOOTSAOISSSSSS+'OIOSSSOSSA.SE505ISISSO SSOIOSOSZ500.55555355 7129S