This example demonstrates the reading of the USB Gamepad in the Nucleo.

Dependencies:   mbed

Intro

This example demonstrates the reading of the USB Gamepad in the Nucleo.

Parts

STM32 Nucleo F446RE
USB Connector
LED 2pcs
Register 470 ohm 2pcs
Breadboard
Wires

Wiring diagram

/media/uploads/beaglescout007/nucleo_ex04_usbpad.png This circuit diagram was created by fritzing.

/media/uploads/beaglescout007/usbcon.jpg

USB con.Nucleo
GNDGND
+PA_12
-PA_11
5V5V

https://youtu.be/EYIukjwJSew

Original Library

Revision:
0:b5f79b4f741d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 15 11:39:04 2016 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+#include "USBHostGamepad.h"
+
+USBHostGamepad *pad;
+
+// LED
+DigitalOut red(PB_5);
+DigitalOut yellow(PA_10);
+
+int main()
+{    
+    // USB Gmaepad Initialize
+    pad = new USBHostGamepad();
+    if (!pad->connect()) {
+        printf("USB Gamepad not found.\r\n");
+        while(1);
+    }
+    
+    while(1)
+    {
+        USBHost::poll();
+        
+        red = pad->report[4] & 0x20;
+        yellow = pad->report[4] & 0x40;
+        
+        printf("%02x %02x %02x %02x %02x %02x %02x %02x\r\n", pad->report[0],pad->report[1],pad->report[2],pad->report[3],pad->report[4],pad->report[5],pad->report[6],pad->report[7]);
+        wait_ms(16);
+    }
+}