Programming in C#


Hi, is there any way to program the BrickPi or Raspberry Pi in C# or is it just in C and Python?


Hey Zewwo! Not yet. Can you program in C# on the Raspberry Pi? And if so, has anyone opened up the GPIO’s on the RPi for that?


Well, I haven’t started programming my RPi yet so no I haven’t.
I heard there was Mono-C# but I’m not sure it will work or not with the BrickPI.


I am just trying to get it running. But I did not succeed yet. The serial interface is working in loopback with mono. But the brick is not answering when I send the message to it.


Just as I wrote it I got the solution. There is a bug in mono for which there is a workaround given in

Now I will implement a class for communication with the BrickPi …


Ok … First implementation is done … The Touch-Sensor example is already working … if someone is interested please let me know.


Hey Pingineer, we’re really interested. Have you considered sharing the code? Maybe you can put it up online?


I am still testing … the motors are not working yet. I can put it up when I managed at least that.


Where should I publish the C#-code? I think it is working so far.


Hey Pingineer! We would love to see the code! If you have a github repo, we would love to take a look at the code, try it out. Do you have a github account?

Also, what did you have to do to get this setup and running? Did you make any changes to the Pi? What image did you start with?


You can find the code here.

I took the recommended BrickPi Wheezy Image. Then I installed the mono package with something like that

sudo apt-get install mono-complete

I am using ‘geany’ as editor for the files. The command

gmcs -out:BrickPi.exe BrickPi.cs BrickTest.cs

compiles the source code. With

mono BrickPi.exe

you can start the program.