Toolbox.NETMF.Hardware.ThumbJoystick


Toolbox.NETMF.Hardware.ThumbJoystick(HorizontalPin, VerticalPin, PushPin, InvertHorizontal, InvertVertical)
  • HorizontalPin The analog pin for the horizontal movement
  • VerticalPin The vertical pin for the horizontal movement
  • PushPin The push button pin
  • InvertHorizontal When true, horizontal values are inverted
  • InvertVertical When true, vertical values are inverted

Methods

  • Dispose() Cleans up the object, releasing all pins

Properties

  • InvertHorizontal When true, horizontal values are inverted
  • InvertVertical When true, vertical values are inverted
  • HorizontalValue The value of the horizontal position
  • VerticalValue The value of the vertical position
  • PushValue True when the joystick is pushed

How to connect

Toolbox.NETMF.Hardware.ThumbJoystick.png

Sample code in C#

// Declares the joystick
ThumbJoystick Joystick = new ThumbJoystick(new Netduino.ADC(Pins.GPIO_PIN_A0), new Netduino.ADC(Pins.GPIO_PIN_A1), Pins.GPIO_PIN_D2);

// Prints all values from the joystick every second
while (true)
{
    Debug.Print("Horz:" + Joystick.HorizontalValue.ToString() + " - Vert:" + Joystick.VerticalValue.ToString() + " - Sel:" + Joystick.PushValue.ToString());
    Thread.Sleep(1000);
}

Sample code in VB

' Declares the joystick
Dim Joystick As ThumbJoystick = New ThumbJoystick(new Netduino.ADC(Pins.GPIO_PIN_A0), new Netduino.ADC(Pins.GPIO_PIN_A1), Pins.GPIO_PIN_D2)

' Prints all values from the joystick every second
Do
    Debug.Print("Horz:" + Joystick.HorizontalValue.ToString() + " - Vert:" + Joystick.VerticalValue.ToString() + " - Sel:" + Joystick.PushValue.ToString())
    Thread.Sleep(1000)
Loop

Related documents

Last edited Jan 1, 2013 at 8:21 PM by Garrcomm, version 3