ArduinoLibCSharp: C# library to interact with the Arduino directly

Hi everyone,

I have just released a first version of a Arduino related C# library on github.

Compatibility note: I have tested with UNO boards exclusively, minor adaptations will be required for other architectures.

ArduinoDriver (library)

An ArduinoDriver can be created in order to communicate with an attached board (through sending messages). The available commands are mimicking the functions in the Arduino Language libraries itself (read / write analog and digital outputs, set pinmodes, send tone / notone ,...), so most Arduino snippets found online can be directly ported to work with the ArduinoDriver instead.

    const byte pin = 8;
    var driver = new ArduinoDriver(true);
    driver.Send(new ToneRequest(pin, 200, 1000));

For this to work, the C# ArduinoDriver library implements a serial communication protocol with a corresponding listener for the Arduino.

The protocol supports:

  • Handshaking and version negotation
  • High speed communication
  • Fault tolerance and error correction (fletcher-16 checksums)
  • Automated deployment of the listener code to the Arduino

ArduinoUploader (library)

The ArduinoUploader library talks to the Arduino's bootloader directly through a dialect of the STK-500 protocol in order to flash the memory on the device with the contents of an Intel HEX file.

The solution comes with a seperate ArduinoSketchUploader command line utility which can be used to upload compiled sketch programs to the Arduino directly without requiring interaction from the Arduino IDE or AVRDude.

Sample Code: Playing the Super Mario Bros "Underworld" theme

In a sample project, the above libraries are used to play this retro tune on the Arduino directly from a C# program.