How to control arduino by a pc with c++ - c++

I want to control my arduino board by my own c++ or java programme. Basically I want to get values from arduino. And perform some tasks based on that values. Simply,I have connected a potentiometer to arduino and I want to read its value in my programme.

You can use the telecommand to control the arduino from your pc. pc will send a string, and a program for the control of the input string on arduino

Your question is very broad so its difficult to give a direct answer, but the normal way is to use serial coms via a USB cable. In your Arduino code use either Serial or SoftwareSerial to open a connection. In your C++ application you will open a connection to the same COM port your Arduino is connected to.
There is some example code on the Arduino website:
http://playground.arduino.cc/Interfacing/CPPWindows
It's then up to you to decide on a protocol for passing data back and forth. This depends entirely on your needs, so we can't really help you unless you give more information.

Related

Wemos D1 Mini (ESP8266) control with USB

I have a Wemos D1 Mini (ESP8266), flashed with WLED and I want to create an application like .exe and have control on turning it on/off and choose colors. Does anyone have any idea how I can do without to connect on wifi and just do everything via USB?
To control the WLED firmware over USB, you would use the firmware's ability to be controlled over a serial connection. It looks like you would open the virtual serial port that appears when you plug in the device, at a speed of 115200, and then you take the same JSON that you would POST to /json/state for controlling it over WiFi, and instead send it over the serial connection, and get your responses back over the serial connection.
You could also implement the TPM2 protocol, or the Adalight protocol (which doesn't really seem to be documented except in code), as those are also supposed to be supported.
If you want to do all this in C++ on Windows, you might start by reading the (very old) Windows tutorials for Win32 API serial port programming. If you only want to target Win10 or newer, you could learn C++/WinRT and then use the new WinRT serial APIs. Or you could consult the answers to this question about serial programming on Windows.

Reading output data from COM port using C++

i have a board and a GPS,accelerometer,gyroscope onboard.
I'm connecting the board to the computer by using a TTL-232R-3V3 ,which is a USB to TTL Serial Cable (3.3V).
After installing the drivers, the assigned COM port is the number 3.
I'm able to read the output simply by using a serial monitor (i've tried with the one included in the Arduino IDE, just for try).
Now i need to create a C++ program which allows me to take the output of the board and store the datas in vectors.
Do i need any libraries? What's the best procedure to do it?
Thanks in advance!
In my company I used the boost library to read from a COM port. It includes the boost::asio::serial_port class to handle this kind of communication.
I used this code snippet for orientation and wrote my own wrapper class, for the needs of the project I was in.
You can take this:
http://www.codeproject.com/Articles/992/Serial-library-for-C
Or if you use Qt, i think there is also a lib from Qt to do this.

Simulate traffic over virtual com port

I'm having a project with Arduino(s) and I would like to build a testing environment so I will be able to do end-to-end integration before testing on the real stuff.
I have a C# program that controls the actions sent to an Arduino, using serial port. The Arduino do some calculations and send back the results back to the C# controller.
I do not want to change the C# program. I do have to implement a program that runs the arudino code and transmit it to a virtual com port I've already created, so the C# program could read it.
Can you please give me some guidance how to write to the virtual com port ?
The Arduino is written in C++, so I guess the solution should be implemented in C++ also.
I noticed to the existance of the tcomport, but it's written in Delphi, so I can't see how I can use it with the C++ code.
Thanks
This question will be closed pretty quickly, since you're looking for a tool or library, which is technically off-topic.
That being said, you might want to check out com0com. This creates a couple fake comport that are "connected together". You would have your program use one, then write another program that simulates the Arduino connected to the other port.
Another solution is to have an interface abstraction between your code and the serial port code. You can then implement that interface to pretend to accept data written to the fake "com port" and produce whatever data you wish in response. This way, you can have the "loopback" and "simulator" contained within your own code.

Communication from C++ to Arduino Programming language on OS X

I have been scouring the internet for some time now trying to figure out how to send data from C++ (which will read an input .txt file) to an Arduino. Because there does not seem to be a native way in Arduino to read files directly, I chose to use C++ to read the file and then send it over to the Arduino. The primary method of doing this seems to be communicating via Serial. So my question is this:
How do you communicate to Serial in C++ (using an OS X device) and subsequently read it in Arduino? Further, are there other, simpler methods of transferring data to Arduino via C++ or natively in Arduino?
Take a look at boost asio or Qt Serial Port.
Both are portable versions for serial-communication with C++.
There is no other option, which could be simpler than serial communication.

C++ USB library

Is there a library/method for communicating with a microcontroller (Arduino)?
Basically, I need a method of receiving and sending data between the PC and the Arduino. I don't know what library to use, so I'm asking you. The data I'm going to send is little. Maybe 500 bytes back and forth. Everything is happening in Visual C++ 2010, in a console application.
libusb seems to be one of the best choices in your case. This is a lightweight, widely-used, open-source, cross-platform and well-documented C library.
termios also works fine. I've been using it to connect an Arduino to a Raspberry Pi (Linux) via serial link (USB). You could find some useful code snippets here.
Boost ASIO works well. Have a look at Stack Overflow question Reading messages from a serial port with Boost Asio. I recently had to write some code for communicating through the serial port, and I used an Arduino Uno to test it.
If you install the FTDI driver for your Arduino board, Windows will recognise it as a COM port, and you can communicate with it as if it is a normal serial port.
Yes, ArduSerail is a SUPER easy to use C++ library to interface with Arduinos on Windows platforms via USB.