Netduino home hardware projects downloads community

Jump to content

The Netduino forums have been replaced by new forums at This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

My first Netduino project

  • Please log in to reply
1 reply to this topic

#1 Matthias Thiele

Matthias Thiele

    New Member

  • Members
  • Pip
  • 1 posts

Posted 26 October 2010 - 07:58 PM


I am new to the Netduino and I would like to share my first projet: a class for a rotary encoder (e.g. from Alps STEC 12E8). It might be useful for a radio-volume controls or the selection of menu entries. The example adapts the blinking LED example and changes the blink time by the encoder.

All you have to do is to connect the two encoder lines and the switch with three Netduino input ports and create a "RotaryEncoder" object. Register an event handler for the switch or the rotation and you are ready.

            rot = new RotaryEncoder(Pins.GPIO_PIN_D13, Pins.GPIO_PIN_D11, Pins.GPIO_PIN_D12);
            rot.setRange(1, 1000);
            rot.OnMove += button_OnMove;

            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
            while (true)
                led.Write(true); // turn on the LED
                Thread.Sleep(i); // sleep
                led.Write(false); // turn off the LED
                Thread.Sleep(i); // sleep

Of course you need an action method to do any useful work

        static void button_OnMove(uint data1, uint data2, DateTime time)
            i = (int)data1;
            Debug.Print("Tick " + i + "    - Direction " + data2);

The complete source code and an example is attached to this entry. I hope it will be useful for someone. I will expand it in the future with a progressive count (fast spinning will count even faster - in steps by 2, 5 or 10, slow spinning counts with the normal precision).

Bug fixes or corrections will be welcome.

Attached Files

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 26 October 2010 - 08:28 PM

Hi Matthias, This is great; thanks for the showing this off and contributing it to the community! Oh, and welcome to the Netduino community... I'm looking forward to seeing what you build next. Chris

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.