I want a C++ program that I wrote to communicate with my Arduino. The C++ program essentially asks a user how many tickets they want to print. I want this value to be sent to the Arduino to determine how many times the Arduino needs to actuate a relay. I have been searching around for some existing code but haven't found anything that stands out as what I am looking for. Any guidance or points in the right direction would be greatly appreciated.
Agreed, its far easier in C#, however it may be too late to transpose an entire app. Here is some info on how to do it on windows ( without C#, its method is far simpler ). This is for C++, however any language that can use the windows API has access to the same functions, and possibly easier ways.
I can't remember off hand their names, however there are some open source serial implementations which wrap this functionality into a nicer interface.
What platform does your program run on, I.e. Windows, Mac, other? How are you connecting to the arduino, i.e. USB, wifi, other?
If you are connecting via USB then you simply need to find and open the arduino's serial port. How you do that will depend on what environment your program is running on. You should have no problem googling for example code on how to do that.
My program will run on Windows and connect to the Arduino via USB. So I will google information about opening the Arduino's serial port.
I am not familiar with C#, I need to look in to it in the future. I am currently in the process of learning C++ and have mediocre C programming abilities. So it's not that I don't want to use C#, it is that I don't have any knowledge in that language and unfortunately I also I don't have the spare time to direct towards learning it at the moment.
Again, I appreciate the links and will meddle around with this information to see if I can get where I need to be. I will update with any progress.
Why not use/learn the API for com port communication then you are pretty much free to use what ever language you want to provided it supports the standard Win32 API calls.
In Unix it's as easy as open("/dev/ttyUSB0"...)
I've heard Windows starting from NT implements many BSD-like api's so I would expect it to have a similar open call as well.
You could also use a class library that abstracts the OS layer to allow for portability between windows/mac/unix.