christophediericx / arduinodriver Goto Github PK
View Code? Open in Web Editor NEWA .NET library for controlling an Arduino board directly through a USB (serial) connection.
License: MIT License
A .NET library for controlling an Arduino board directly through a USB (serial) connection.
License: MIT License
Hi there again,
Thanks for the new features in the latest version. I noticed a few issues while testing it on my project:
2)Also I'm not sure whether it's the project which I'm working on but I'm experiencing drops in performance whenever I switch between different method arguments on the Driver e.g. switching between arduinodriver overload 1 and 2 and switching from Leonardo to Uno boards.. I'm suspecting serial port event handler but this problem is way over my head :(
Thanks again for putting this out there for us non-engineers!
I have an issue if I try to upload to a Mega2560 I can do it once but if I stay in the app and try a second time it does nothing. It just waits and I have crash out of my app. If I restart my app I can then upload again. I know its not my app as it doesn't do the same with NanoR3 or UnoR3, they work. I know its not my board as I dont have the same issue with the Arduino IDE.
Hi Chris.
I've been testing your interface for use as a bridge between real-things and a flight-simulator model via the Arduino. Figured out a few problems you might want to include in the next version to save others from head-scratching !!
1/ ArduinoListner.ICO file ..
You've got a bug %line 127 for digitalPinToRead .. it should use data[2] instead of data[0].
2/ In latest release - ArduinoDriver.cs - method InitializeWithoutAutoBootstrap()
You have a port.Close() after the handshake... this shouldn't be there (creates load of problems)... change the code to be
if (handshakeResponse == null)
{
port.Close();
Port.Dispose();
throw exception..
}
Cheers
Gary
Hello,
I was wondering if there is any future plans for implementing the Arduino loop, maybe as a lamda expression or something?
Thank you,
Vlad V.
I wonder if it was already done some testing with Arduino Due to this library.
Does this library supports Wemos D1 Mini, NodeMCU or other ESP8266 based boards? If not Please also add support for ESP8266 based boards... Thanks !
I have just cloned this project and restored missing Nuget packages, yet everywhere I see in code the type ArduinoModel
is highlighted in red because the compiler doesn't recognize it from anywhere. Is there a setup step or a dependency on another project i have missed or something? I can't wait to get started with this amazingly helpful looking tool.
Driver + Sample after running throw following exception:
"Unable to establish sync after 20 retries!"
But board is OK, because I can program it using Arduino IDE.
This would be very useful when working with shift registers.
Hi,
i want to use you library in Unity3d and i will get an error which i don't know to handle. I've switched your Project and Unity3D to .net 4.6 and both are working correctly (separate).
The ArduinoUploader.dll and RJCP.SerialPortStream.dll are compiled also with 4.6
When i will start the Project in Visual Studio the Music sounds out of the Arduino correctly
I've copied the following files to unity:
ArduinoDriver.dll
ArduinoDriver.dll.config
ArduinoUploader.dll
IntelHexFormatReader.dll
NLog.dll
RJCP.SerialPortStream.dll
RJCP.SerialPortStream.xml
When i will start my Project and send the Music to the Arduino the yellow LED is blinking and i will get the following error:
IOException: Device Error
RJCP.IO.Ports.SerialPortStream.WriteCheckDeviceError () (at :0)
RJCP.IO.Ports.SerialPortStream.WriteCheck (System.Byte[] buffer, System.Int32 offset, System.Int32 count) (at :0)
RJCP.IO.Ports.SerialPortStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 count) (at :0)
ArduinoUploader.BootloaderProgrammers.ArduinoBootloaderProgrammer.Send (ArduinoUploader.BootloaderProgrammers.Protocols.IRequest request) (at :0)
ArduinoUploader.BootloaderProgrammers.Protocols.STK500v1.Stk500V1BootloaderProgrammer.EstablishSync () (at :0)
ArduinoUploader.ArduinoSketchUploader.UploadSketch (System.Collections.Generic.IEnumerable`1[T] hexFileContents) (at :0)
I know ist not directly your issue but i'm hoping that you can identify the Problem when you see the error message. May be some files missing?
THX Forward!!!
I want some Arduino lib but i don't know how to use Arduino lib in c#
I searched it so i get some info about dll but how to make arduino lib to dll, too
how can i do it?
Please could you add "external analog reference" functionality to your program as without it the Arduino Uno R3 has very poor analog read accuracy as Vcc (default reference) varies.
I have looked into adding it in myself.
The easiest way, I assume, would be a to add the command to ArduinoListener.ino file but I was unsuccessful in compiling the new required ArduinoListener.ino.UnoR3.hex due to Arduino IDE compiler errors.
The other option I believe is to add the command set to all required files (to the library) but again without the ability to generate the required hex file this would be all for nothing.
Thanks
DynastyORiGiN
Hi!
Thanks a bunch for this library first off, amazing effort.
I haven't had much time yet to parse and implement majority of features in this,
is it possible to upload the code to the microcontroller or produce an arduino code from the library?
Thanks in advance.
I am writing high to digital pin 52 on my ATMega2560 (Made by Elegoo/Amazon, not arduino) and the write function is not behaving correctly. I can tell that the arduino is receiving the serial commands but the high command is not putting out a full 5v to the digital pin when I turn it on. I can see the LED connected to PIN 52 turns on but I have to have all lights off in my room to see it. I tested the chip by uploading a sketch from arduino IDE and it behaves as expected with a nice bright flash from the led.
Here is the code I am using:
using ArduinoDriver;
using ArduinoDriver.SerialProtocol;
using ArduinoUploader.Hardware;
namespace StillController
{
class Program
{
static void Main(string[] args)
{
var driver = new ArduinoDriver.ArduinoDriver(ArduinoModel.Mega2560, "COM7", true);
driver.Send(new DigitalWriteRequest(52, DigitalValue.High));
System.Threading.Thread.Sleep(1);
}
}
}
hello I'm a noob who is trying to understand how the arduinodriver is working, but i can't find anything basic how the driver is working.
could some maby send me sort of a sample to turn on a led.
Would it be possible to make this library work with the chipkit firmware v 1.3.1 in order to be able to use it with OpenBCI?
Thank you very much.
Will this cause an error?
when I execute the sample code against my arduino uno, which does not explicitly say it is r3 (so i am assuming it isn't) it fails on the handshaking. The arduino works with the normal arduino IDE.
is this driver compatible with the older uno?
Hi,
I was wondering if it would be possible to add support for Leonardo boards.
Thanks!
Any chance support for the Arduino M0 Pro could be added?
I'm assuming it's not already in since I didn't see it on the readme, but if you could get support for the Arduino 101, that'd be awesome.
Hi,
Thank you very much to share your fantastic job with us.
I wanted to know if you think to include One-Wire and I2C possibilities and a 3.5 framework version to try to use it with Unity 3D.
Thank you again.
I constantly program Leonardos on Lattepandas(DFRobot) and it always crash if I use this program on manufacturers bootloader, but using Arduino IDE always work on first;
Programming after new bootloader is in does always work;
It sticks on: COMN - Port still present...
Does anyone know how to read in an analog value to c# from the Arduino UNO using the ArduinoDriver? I am trying to read in the value from a pressure sensor connected to the Arduino and store it as an int in my c# code. Thanks!
Thanks for the great contribution! I am new to the coding world.
Can you give an example how to read an Analog input? I can use Digital WriteRequest to toggle the Digital pin. I saw your Buzzer example. Do you need to define the PinMode first? Thanks!
Frank
As it stands now reading and writing multiple values at once can be quite slow. Writing a digit to a 7-digit display takes around 85 ms. That is a long time taken just to write output to seven pins.
I propose that new options are added to the protocol. The names are unimportant so I'll refer to the additions as ExtendedRead
and ExtendedWrite
. These cover both analog and digital operations.
The protocol extensions would be similar to the current implementations. The extensions would send the amount of operations (operation referring to reading or writing a pin) to the board, along with the needed pin information to complete the operations.
For reading this would simply be a number, eg. 3, and a list of the pins to read. An example could look like this:
var response = driver.Send(new ExtendedDigitalReadRequest(3, 4, 5);
The only parameter to the ExtendedDigitalReadRequest
constructor would be a single params
parameter containing all the pins.
The response to a ExtendedReadRequest
would be similar to the current ones. Instead of containing the readings for a single operation it would contain an array with an entry for every operation requested. The type of the array depends on the type of ExtendedReadRequest
. The type would be DigitalValue
for digital and byte
for analog. The ordering of the response would have to match the ordering of the original request.
Another option is wrapping the pin information in a struct. That would make the relationship between pin and reading more explicit, but would also require more protocol overhead.
Writing to multiple pins is slightly trickier. I suggest wrapping the pin and DigitalValue
value in a struct.
struct DigitalWriteInfo { byte Pin { get; set; } DigitalValue Value { get; set; } }
The constructor is omitted from the above declaration. An example call with three values would then look like this:
var response = driver.Send(new ExtendedDigitalWriteRequest(new DigitalWriteInfo(2, DigitalValue.High), new DigitalWriteInfo(3, DigitalValue.Low), new DigitalWriteInfo(4, DigitalValue.Low)));
The syntax is very verbose, and there might be a better way to handle it, but I believe the intention is clear.
The response to a ExtendedWriteRequest
is similar to the response to a ExtendedReadReqeuest
. I believe the explanation and reasoning in that section also covers the current section.
Feel free to ask for clarification if you need it.
Hello I made a library using your awesome one and I want you to look at the library, sorry for my english is not good https://github.com/aleGuardiola/DynamicDriver
Hi,
Is it possible to add support for the SparkFun 9DoF Razor IMU M0 (SEN-14001)?
https://www.sparkfun.com/products/14001
Thanks,
Julio
I'd like to use the driver with the Arduino Nano.
The Debug Start options in the SketchUploader project configuration expect the following command line arguments:
--port=COM3 --file="C:\Users\chris\Desktop\sketch.hex"
Can you clarify what this file is supposed to contain? Can I generate it with the sample code, or do you need to share it along with the rest of the project?
Hello! Thanks for taking the time to write up this library. I'm having an issue I can't pin down. When I try to create an instance of ArduinoDriver I get an UnauthorizedAccessException stating it couldn't access the COM port. I ran your compiled sample code and it worked just fine. However, I tried compiling the source for the sample code and it receives the same error.
I'm using a UNOR3 via USB and VS 2015. Communications should be fine since your compiled sample worked flawlessly, but my test programs and me compiling your sample source does not. Let me know if you need additional information. Nothing else should have a hold on the COM port; I also tried manually entering the COM port using the overloaded constructor.
Another thing I noticed is that even though I have the ArduinoDriver Nuget Package installed and have access to the DLL, I need to specify the ArduinoDriver class using the namespace like so: "ArduinoDriver.ArduinoDriver". Adding "using ArduinoDriver;' doesn't remove this issue. I don't think it's a problem, just found it odd.
I'd like to test out your library and see if it fits my needs, but I can't get past the COM access. Please advise on what I should do to get past this. Thanks!
i want to use a sevsegshift library or control a sevent segment library, or a stepper motor. How i can use custom library to control in c#?
Hi,
Firstly, I apologize for the such basic question. I'm trying to do DigitalWriteRequest, but seems it's not working properly because pin value doesn't change. DigitalReadRequest returns "High" value instead of expected "Low" value.
Is there something wrong with my code below?
using (var driver = new ArduinoDriver.ArduinoDriver(ArduinoModel.UnoR3, true))
{
driver.Send(new DigitalWriteRequest(13, ArduinoDriver.DigitalValue.Low));
Thread.Sleep(1000);
var digitalReadResponse = driver.Send(new DigitalReadRequest(13));
var readValue = digitalReadResponse.PinValue;
}
Thanks,
teapottiger
Hello,
I would like to suggest adding a way to control servo motors with this library.
Usually, with an Arduino, one would simply use the "Servo.h" library to control a servo motor. However, when using this library, one must recreate the whole PWM functions since a servo motor is expecting a 40Hz frequency which isn't really obtainable by using analogWrite commands.
I beleive it could help greatly to have such a function :) (if there already is one and I simply couldn't find it, I'm sorry and could you please point me in the right direction?)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.