This project is read-only.


Toolbox.NETMF.Hardware.RotaryEncoder(PinA, PinB)
  • PinA Pin A of the rotary encoder
  • PinB Pin B of the rotary encoder


  • Rotated(Unused, Value, Time) When the knob is rotated, this event is triggered.

How to connect


Sample code in C#

public static void Main()
    // Initializes a new rotary encoder object
    RotaryEncoder Knob = new RotaryEncoder(Pins.GPIO_PIN_D0, Pins.GPIO_PIN_D1);
    // Bounds the event to the rotary encoder
    Knob.Rotated += new NativeEventHandler(Knob_Rotated);
    // Wait infinitely

/// <summary>
/// The value has been changed
/// </summary>
/// <param name="Unused">Not used</param>
/// <param name="Value">The new value</param>
/// <param name="Time">Time of the event</param>
static void Knob_Rotated(uint Unused, uint Value, DateTime Time)
    Debug.Print(Value == 1 ? "Clockwise" : "Counter clockwise");

Sample code in VB

' Initializes a new rotary encoder object
Dim WithEvents Knob As RotaryEncoder = New RotaryEncoder(Pins.GPIO_PIN_D0, Pins.GPIO_PIN_D1)

Sub Main()
    ' Wait infinitely
End Sub

Private Sub Knob_Rotated(Unused As UInteger, Value As UInteger, time As Date) Handles Knob.Rotated
    If Value = 1 Then Debug.Print("Clockwise") Else Debug.Print("Counter clockwise")
End Sub

Related documents

Last edited Jan 1, 2013 at 9:17 PM by Garrcomm, version 2