C# code that runs on Raspberry Pi under Mono with motor control via I2C
JavaScript CSS C# HTML PowerShell ASP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Connects the Adafruit 16-channel PWM/Servo Shield (PCA9685) to the Raspberry Pi via i2c.

Demonstrates the use of mono & c# to control a servo, stepper and 9V DC motor from the Raspberry Pi.

The project uses:

Circuit Diagram


A lego ping pong launcher was constructed to showcase the motors in action.



The Visual Studio solution expects raspberry-sharp-io to be cloned into a sibling directory.




The code intially targeted Mono 2.x with a WinForms UI to allow interactive control of the motors (WinForms running in X-Windows). It now targets mono 3.x which was compiled on the pi so as to take advantage of hard float and enable the use of async/await. WinForms on mono 3.x is broken at the time of writing so a web based UI was required.

SignalR is demonstrated in two ways

  1. Client-Server-Client topology (eg: pi-IIS-iPhone)

SignalR hub is hosted on IIS 8 with two hubs: one hub for a web browser remote control client using jQuery mobile; a second hub for the pi itself to connect to via the signalR c# client. This works well, apart from the requirement of IIS 8 as the mediator. see:

rpi.console/rpiconsole.exe -m=SignalRTest
  1. Self contained/hosted console app, using Nancy, SignalR and NoWin.

SignalR on mono cannot host websockets and the transport falls back to Server Side Events. Response is very slow while dragging a slider backward and foward with several seconds lag before the server sees this response. Response is even slower using Katana as the web server. see:


A video the ping pong launcher can be seen here.

Later Projects#

Other projects that make use of this code base... ##Alarm Clock ## An alarm clock. The source code is contained in this repo.

Alarm Clock

Lego Marble Sorter

A Lego marble pump & sorter using OpenCV. The source code in in another repo but references projects in this repo.

marble pump