Description
This example project show how you can blink a LED in just a few lines of code. For this a comand line application is used but PeekyPokey can also be programmed in a graphical manner using Windows Forms or any combination of the two.

Introduction
PeekyPokey coding is very easy in either C# or VB.NET using the free Visual Studio Express 2010+ IDE under Windows. You can of course also use any of the corresponding commercial versions of Visual Studio.

A simple yet informative example would be the classic "Blinky" application that blinks a LED. The application code below periodically turns the rightmost of the on-board LEDs on and off every 200 milliseconds.

Here's what the code looks like in C#:

using PeekyPokey;

namespace Blinky
{
    class Program
    {
        static void Main(string[] args)
        {
            // create a digital output port
            var LED = new OutputPort(Device.Pin.Gpio0);

            // loop
            while(true)
            {
                // turn LED on and wait 200ms
                LED.Value = true;
                System.Threading.Thread.Sleep(200);

                // turn the LED off and wait 200ms
                LED.Value = false;
                System.Threading.Thread.Sleep(200);
            }
        }
    }
}

 

Check out the Projects page for more examples on how to code and also how to wire up your gizmos in order to do something more useful than simply blinking a LED.

Last edited Mar 6, 2014 at 9:57 PM by hanzibal, version 15