Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
So I have an arduino uno board (no won't make the same mistake next time) running a c program, in there I have some variables that needs changing depending on what's happening in my main program that's written in c#. The communication is one way, as the response comes from somewhere else, I'd just like to send a "start + address + data" then "stop" packages. something like

to start 1 01 1 then to stop 0. (maybe 0 00 0)

The question is does it worth for me to try and understand how my usb drivers will communicate, or would it be possible to send the data in another way? It's the last part of my uni project so it's kind of urgent, im looking for teh simplest solution possible (usb didn't sound like it from others questions :S.. but it looks good when i want to present it...)

For me the tricky part is both writing the c for the arduino with any communication type ( as unlike it was advertised really most examples are written using it's own language) and writing c# for usb. ( I wrote a serial sender that works, thinking that I'll chop up a cable and send data that way... but i'm not convinced that that could work even at 300 baud rate...)

or my final idea was to save stuff into a txt document and use GoBetwino to read from it... that's not ideal as my application would really need to be as fast as possible, plus i can only image that the arduino would need to poll for changes in the doc... again not ideal.... so if anyone knows slightly more about how to send 4 bytes from a (form) application to my arduino ... please shout!
Posted
Comments
[no name] 14-Apr-14 19:04pm    
What are you missing? This question has been answered zillions of times on Arduino forums and elsewhere. You don't need to hack cables. When you plug your arduino in to usb a com port is created. Use that. http://playground.arduino.cc/Csharp/SerialCommsCSharp

The best way to do it is over a serial connection as all Arduinos have serial interfaces. You can get a USB-to-Serial converter and talk with the board over a COM port. That's been documented thousands of times all over the web. And, yes, it works over just about any speed.
 
Share this answer
 
Comments
[no name] 14-Apr-14 23:12pm    
This is not the way if you wish to talk directly to the PC. All Arduinos create a com port when you plug them in via usb.
Dave Kreskowiak 15-Apr-14 0:21am    
And?? That's communication over a serial link! How is that not "talk[ing] directly to the PC"??
[no name] 15-Apr-14 0:35am    
Well yes it is. There is however a direct path for doing this which I have enunciated. This is built in without any other stuff required for this very purpose and supported by Arduino libraries. This would seem to be the OP's ideal choice IMHO. I am sorry if my comment was a little curt.
Dave Kreskowiak 15-Apr-14 7:40am    
You told him the exact same thing I did.
[no name] 15-Apr-14 19:34pm    
I thought mine was specific while yours general. However I don't want to argue.
I assume you are using Windows.

Plug in your Arduino to PC using your usb cable. Open Device Manager. Look for ports(COM & LPT ). There you will find your Arduino identified. Mine is COM3. Look at "Port Settings" mine are 9600,8,none,1,none.

Now use this code:

http://playground.arduino.cc/Csharp/SerialCommsCSharp[^]

As long as your port is set to 9600 this will work - if not modify the C# code to your baud rate at this line:

C#
currentPort = new SerialPort(port, 9600);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900