Meadow Applications

Meadow projects are based on .NET framework console applications. You’ll likely notice some similarities as you build Meadow applications. To create a new Meadow application, you’ll create a new Meadow application and in static void Main, launch a Meadow.IApp:

using System.Threading;
using Meadow;

namespace HelloLED
    class MainClass
        static IApp app;

        static void Main(string[] args)
            // instantiate new meadow app
            app = new LEDApp();

Meadow Package

When you create a new Meadow application, the Meadow core package should be automatically added. It can be manually installed via NuGet:

> nuget install Meadow

App Class

The main Meadow application class should inherit @”Meadow.App”, which provides a way for Meadow OS to notify the application of system events, such as going to sleep or waking up.

Currently, we don’t enforce the use of App, but in a future build of Meadow, it’ll scan your Meadow application assembly for a class that implements IApp and launch that automatically. So, it’s a good practice to use this pattern now.

The App declaration requires two generic parameters; D, and A, representing the device type and the application class type, respectively. For D, you’ll need to pass a Meadow.IDevice that represents the board you’re using, such as F7Micro. For A, you should pass the typename of your application class itself.

For example, if your app class is called LEDApp, and you’re using a Meadow F7v2 Micro board, your LEDApp declaration would look like the following:

public class LEDApp : App<F7MicroV2, LEDApp>

If you’re using a v1 board, you’ll use this signature:

public class LEDApp : App<F7Micro, LEDApp>

D = Device

Specifying the D parameter sets the current device so that it can be accessed via the Device property of the IApp:

var redLED = new DigitalOutputPort(Device.Pins.OnboardLEDRed, false);

A = App

Specifying the A type parameter in App allows the app class instance to be available via the Current property and strongly typed:

MyApp myApp = MyApp.Current;

Therefore, any public members are also available without having to cast. For instance, if your app class had a property called InstalledName, it could be accessed as follows:

var name = MyApp.Current.InstalledName;

Sample Meadow Application

Here is a complete example of an application that cycles through some colors on the onboard LED:

class LEDApp : App<F7Micro, LEDApp>
    private IDigitalOutputPort redLed;
    private IDigitalOutputPort blueLed;
    private IDigitalOutputPort greenLed;

    public LEDApp()

    public void CreateOutputs()
        redLed = Device.CreateDigitalOutputPort(Device.Pins.OnboardLedRed);
        blueLed = Device.CreateDigitalOutputPort(Device.Pins.OnboardLedBlue);
        greenLed = Device.CreateDigitalOutputPort(Device.Pins.OnboardLedGreen);

    public void ShowLights()
        var state = false;

            state = !state;

            Console.WriteLine($"State: {state}");

            redLed.State = state;
            greenLed.State = state;
            blueLed.State = state;

Next - Input/Output


These docs are open source. If you find an issue, please file a bug, or send us a pull request. And if you want to contribute, we'd love that too!