Software apps and online services
In this project we're going to control a servo when pressing a push button using Meadow. Everything you need to build this project is included in the Wilderness Labs Meadow F7 w/Hack Kit Pro. We'll create a Meadow Application project and use Meadow.Foundation to easily write the logic.
Meadow.Foundation a platform for quickly and easily building connected things using.NET on Meadow. Created by Wilderness Labs, it's completely open source and maintained by the Wilderness Labs community.
If you're new working with Meadow, I suggest you go to the Getting Started w/ Meadow by Controlling the Onboard RGB LED project to properly set up your development environment.Step 1 - Assemble the circuit
Connect your button and servo like the following Fritzing diagram:
Create a new Meadow Application project in Visual Studio 2019 for Windows or macOS and name it ServoButton.Step 3 - Add the required NuGet packages
Right-click on your ServoButton project and click Manage NuGet Packages. In the Browse tab, search for Meadow.Foundation.Servo and click Install to add it to your project.
Alt-click on your ServoButton project in the Solution Explorer, and click Add => Add Nuget Package to open the NuGet Package window. Search for Meadow.Foundation.Servo and click Install to add it to your project.Step 4 - Write the code for ServoButton
Copy the following code below:
public class MeadowApp : App<F7Micro, MeadowApp>
var servoConfig = new ServoConfig(
servo = new Servo(Device.CreatePwmPort(Device.Pins.D03), servoConfig);
button = new PushButton(Device, Device.Pins.D04);
button.Clicked += ButtonClicked;
// Keeps the app running
void ButtonClicked(object sender, EventArgs e)
In the MeadowApp's constructor the first thing the app does is initialize a
Servo object, passing a
ServoConfig for the SG90 model so it can rotate at its full range. Once Initialized, servo rotates to angle 0 using
RotateTo(int angle); method. Next the app initializes a
PushButton by passing an
IIODevice which is Meadow in this case, and the
IPin which the button is connected (
D04). Now that our button is initialized, we can register the Clicked event handler, and will call
ButtonClicked, which rotated the servo to 75 degrees for one second, and then goes back to its initial position.
Click the Run button in Visual Studio, It should look like to the following GIF:
This project is only the tip of the iceberg in terms of the extensive exciting things you can do with Meadow.Foundation.
- It comes with a huge peripheral driver library with drivers for the most common sensors and peripherals.
- The peripheral drivers encapsulate the core logic and expose a simple, clean, modern API.
- This project is backed by a growing community that is constantly working on building cool connected things and are always excited to help new-comers and discuss new projects.