Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Homepage
ABOUT¶
A simple class for reading a Super Nintendo (SNES) controller's buttons.
HARDWARE¶
The library was developed using the Nordic mKIT and cheap controllers.
NOTE: This controller has a wide VCC tolerance and continues to operate even when the mKIT is running off of a coin cell battery.
+-----------+ | | | +-+ | | +-+--------+VCC | | | +-+ | | +-+--------+CLOCK | | | +-+ | | +-+--------+LATCH | | | +-+ | | +-+--------+DATA | | +-----------+ | | | +-+ | | +-+--------+N/C | | | +-+ | | +-+--------+N/C | | | +-+ | X +-+----+---+GND X X --------- Controller pinout (looking into the female connector)
USAGE¶
After wiring up a controller:
Include the library
#include "SNESController.h"
Create a new object and specify the pins
SNESController snes(P0_20, P0_21, P0_22);
Read and decode the button presses
uint16_t state = snes.read(); if (snes.pressed(state, SNESController::SNES_BUTTON_RIGHT_ARROW)) { ... }
Poll the controller periodically
Ticker ticker; ticker.attach(periodicCallback, 0.05);