This example demonstrates the reading of the USB Gamepad in the Nucleo.
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
This circuit diagram was created by fritzing.
USB con. | Nucleo |
---|---|
GND | GND |
+ | PA_12 |
- | PA_11 |
5V | 5V |
Original Library
- F401RE-USBHost by Norimasa Okamoto
- USBHostGamepad by Yuuichi Akagawa
main.cpp
- Committer:
- beaglescout007
- Date:
- 2016-03-15
- Revision:
- 0:b5f79b4f741d
File content as of revision 0:b5f79b4f741d:
#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); } }