Skip to main content

Meadow.Foundation.Grove.Sensors.Hid.ThumbJoystick

ThumbJoystick
StatusStatus badge: working
Source codeGitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Grove.Sensors.Hid.ThumbJoystick

Code Example

ThumbJoystick joystick;

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

joystick = new ThumbJoystick(
Device.CreateAnalogInputPort(Device.Pins.A01, 1, TimeSpan.FromMilliseconds(10), new Voltage(3.3)),
Device.CreateAnalogInputPort(Device.Pins.A02, 1, TimeSpan.FromMilliseconds(10), new Voltage(3.3)),
null);

joystick.Updated += JoystickUpdated;

return Task.CompletedTask;
}

public override async Task Run()
{
await joystick.SetCenterPosition();

joystick.StartUpdating(TimeSpan.FromMilliseconds(20));
}

private void JoystickUpdated(object sender, IChangeResult<AnalogJoystickPosition> e)
{
Resolver.Log.Info($"Horizontal: {e.New.Horizontal:n2}, Vertical: {e.New.Vertical:n2}");
Resolver.Log.Info($"Digital position: {joystick.DigitalPosition}");
}

Sample project(s) available on GitHub

Wiring Example

ThumbJoystickMeadow Pin
GNDGND
VCC3.3V
RXD01
TXD00