Skip to content
Description

USB is a USB driver module, integrated MAX3421E which adds USB host or peripheral capability to any system with an SPI interface. Ever up for adding the standard USB features on your project? this M5 moudle is the perfect solution.

Series Protocol: SPI

Product Features

  • 1x UAB stadard A port
  • 10x extended GPIO pins
  • extended 3v3, 5v & GND

Kit includes

  • 1x M5Stack USB Module

Application

  • USB keylogger
  • Read and write U disk using M5Core
Documents
Learn

Example

To get complete code, please click here.

NOTE: Before compile this example code, you need to download the corresponding USB library from here. Unzip and copy this library folder to Arduino library path.( This is my pathC:\Users\<user_name>\Documents\Arduino\libraries)

Download the example usb_mouse.ino Plug the USB mouse into USB A port.

  • Hold down the left button to draw white lines.

  • Hold down the right button to draw green line.

  • Press the middle wheel button to clear the screen.

#include <M5Stack.h> #include <SPI.h> #include <Usb.h> #include <hiduniversal.h> #include <hidboot.h> #include <usbhub.h> #include "M5Mouse.h"  // new objects USB Usb; USBHub  Hub(&Usb); HIDBoot<USB_HID_PROTOCOL_MOUSE> HidMouse(&Usb); MouseRptParser  Prs;  // initialization M5.begin(); Usb.Init(); HidMouse.SetReportParser(0,(HIDReportParser*)&Prs);  // handle event coming from usb device Usb.Task(); if(Usb.getUsbTaskState() == USB_STATE_RUNNING) {   Mouse_Pointer(mou_px, mou_py);   mou_px = 0;   mou_py = 0;   /* left button pressed: draw white point */   if (mou_button == 1)     M5.Lcd.drawCircle(StaPotX, StaPotY, 1, WHITE);   /* right button pressed: draw green point */   if (mou_button == 2)     M5.Lcd.drawCircle(StaPotX, StaPotY, 1, GREEN);   /* middle button pressed: clear screen */   if (mou_button == 4)     M5.Lcd.fillScreen(BLACK); } 

 

More information

Schematic

The USB Module with MAX3421E appears in the following collections:

SKU M5-M020