I have an Arduino UNO R3 that I'm trying to interface with using a C++ program I made. The UNO transmits data, and the program receives the aforementioned data. The program and Arduino run well together without a hitch, but when I unplug the UNO from the USB port then plug it back in, it seems like the sketch won't start (for the rest of this post, I'll call this state, the UNO's "frozen" state.)
Interestingly, hitting the reset button while the UNO is operational doesn't put it in a "frozen" state, which is weird to me because I read here that pressing the reset button is the same as unplugging then plugging back in the UNO.
In order to bring the UNO out of the "frozen" state and back into an operational state, I have to open the Serial monitor via Arduino IDE. Once I open the serial monitor, the sketch starts up again with no problems. The UNO transmits data to my program without any problems after I open then close the serial monitor.
Possibly related: When I upload a sketch onto the UNO, the UNO initially transmits junk data to my program, but when I open the serial monitor in Arduino IDE, the UNO becomes operational and starts transmitting valid data again. The UNO reverts back to transmitting junk data when I upload a sketch, and I must open the serial monitor (then close it) every time I want the UNO to become functional.
This leads me to believe that opening the serial monitor somehow jump starts the UNO (or "initializes" it) and I need to know how to do this in my C++ program.
Does anyone know what the problem may be and/or if it's possible for me to "initialize" the UNO myself in my program?
EDIT: Edited above for clarity.