The Digispark > Digispark Projects

[SOLVED] Managed library (C#) to talk to DigiUSB?

(1/2) > >>

[EDIT] Code is linked in my next comment.


I want to write a C# program to control my RGB LED. Is there a library or sample code for how to communicate with the digispark over usb from managed code? I understand what to do on the digispark side, and I understand how it would work from Python (although I haven't tested that yet).

If nobody has tried this yet I guess I'll start with Python and then maybe see if I can port it to managed code, but if you have got this working already please let me know!


A good start would be to take a look at libusb examples for c#

Thanks for the hint!

It took some tinkering, but I\'ve  managed to port to C# using LibUsbDotNet.

I can send values to the DigiBlink program and wrote a simple program that reads values from the usb port (e.g. from the echo sketch) and prints the data to the console.

This is the first time I\'ve used LibUsbDotNet or dealt with the USB port, so no guarantee that this is working for everyone. I\'ve only tested it on my machine (Win8, x64, VS2012, rev2 DigiSpark).

The code is shared on sourcepod. Code is provided \"as-is,\" without any express or implied warranty.

Port of (basic read and write methods):
[EDIT] Updated version with device notification here

Some quick and dirty sample code (the read app is the second part that is currently commented out):

If you use this code (successfully or otherwise) let me know how you\'re getting on!

Awesome - thanks for the wonderful contribution!

No problem, I hope this will help some people and spawn more awesome projects.

I\'ve updated the code to include device change notification. Every time the DigiSpark is connected or disconnected it will raise an event that you can react to e.g. in your WinForms app. The code itself got a little smarter too, it\'ll only try to interact with the DigiSpark when it\'s actually present.
I have a little GUI that allows to change the colors on the DigiBlink and is aware of whether the DigiSpark is plugged in or not. If I have some time this week I\'ll try to clean that up and make it available as well.

For now here the updated library:



[0] Message Index

[#] Next page

Go to full version