Software apps and online services
Project updated to beta 6.2 (released on March 5th, 2022)
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
For this project, search and install the following NuGet packages:Step 4 - Write the code for ServoButton
Copy the following code below:
using AU = Meadow.Units.Angle.UnitType;
// public class MeadowApp : App<F7Micro, MeadowApp> <- If you have a Meadow F7 v1.*
public class MeadowApp : App<F7MicroV2, MeadowApp>
var onboardLed = new RgbPwmLed(
servo = new Servo(Device.CreatePwmPort(Device.Pins.D10),
button = new PushButton(Device, Device.Pins.D04);
button.Clicked += ButtonClicked;
void ButtonClicked(object sender, EventArgs e)
servo.RotateTo(new Angle(75, AU.Degrees));
servo.RotateTo(new Angle(0, AU.Degrees));
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.