Introduction

This class allows you to control Arduino GPIO from Windows apps, with features including:

  • Reading and writing to digital pins
  • Reading analog inputs
  • Controlling servo motors
  • Sending data to devices and receiving data form devices through the I2C Bus

Step 1: Set up your PC

1.Download Visual Studio 2017 Here image2

2.Enable developer mode on your operating system

image4

image5

image6

3.Download LattePanda.Firmata

LattePanda.Firmata is an open-source Firmata library provided by LattePanda, which is suitable for Windows apps developed in Visual Studio. This class allows you to control Arduino GPIO from Windows apps, with features including:

  • Reading and writing to digital pins
  • Reading analog inputs
  • Controlling servo motors
  • Sending data to devices and receiving data form devices through the I2C Bus

Step 2: Set up the Arduino

1.Open Arduino. And select the “StandardFirmata”

image16

2.Select “Arduino Leonardo”

image17

3.Select your COM port

image18

4.Upload the sketch

image19

5.Upload Done!

image20

Step 3: Blink your Board

Create a project or use the sample project. You can find more GPIO example here.

1.Open Visual Studio 2017 and create a new app: createProject1 createProject2 2.Download the LattePanda.Firmata class library

3.Add the downloaded class library to your project Open your Solution Explorer and right-click in the blank area, then add existing item. addClass1 4.Add the following code to Program.cs.

  • Add the following two lines code before the namespace blinkYourBoard.

    using System.Threading;

    using LattePanda.Firmata;

    The first namespace contributes to delay and second is LattePanda.Firmata class library namespace

  • Add the following code in the Main Function

Arduino arduino = new Arduino();
arduino.pinMode(13, Arduino.OUTPUT);//Set the digital pin 13 as output
while (true)
{
// ==== set the led on or off
arduino.digitalWrite(13, Arduino.HIGH);//set the LED on
Thread.Sleep(1000);//delay a seconds
arduino.digitalWrite(13, Arduino.LOW);//set the LED off
Thread.Sleep(1000);//delay a seconds
}

The complete code is as follows:

addCode

5.Finally debug your project Connect your Arduino and click Start start Soon you will find the LED of your Arduino blinking