Skip to main content

Meadow.Foundation.Sensors.Hid.WiiNunchuck

WiiNunchuck
StatusStatus badge: working
Source codeGitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Sensors.Hid.WiiExtensionControllers

Code Example

WiiNunchuck nunchuck;

public override Task Initialize()
{
Resolver.Log.Info("Initialize...");

nunchuck = new WiiNunchuck(Device.CreateI2cBus(WiiNunchuck.DefaultI2cSpeed));

nunchuck.GetIdentification();

Resolver.Log.Info("Update");

//onetime update - could be used in a game loop
nunchuck.Update();

//check the state of a button
Resolver.Log.Info("C Button is " + (nunchuck.CButton.State == true ? "pressed" : "not pressed"));

//.NET events
nunchuck.CButton.Clicked += (s, e) => Resolver.Log.Info("C button clicked");
nunchuck.ZButton.Clicked += (s, e) => Resolver.Log.Info("Z button clicked");

nunchuck.AnalogStick.Updated += (s, e) => Resolver.Log.Info($"Analog Stick {e.New.Horizontal}, {e.New.Vertical}");

return Task.CompletedTask;
}

public override Task Run()
{
nunchuck.StartUpdating(TimeSpan.FromMilliseconds(200));
return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a WiiNunchuck to your Meadow board, connect the following:

WiiNunchuckMeadow Pin
GNDGND
SCLD08 (SCL)
SDAD07 (SDA)
VCC3V3