Go Down

Topic: Communicating with Arduino via Serial (Read 1 time) previous topic - next topic


I am currently working on flashing an LED connected to one of the pins on my Arduino.  I would like it to do it from C++ for Windows and Android.
Does anyone have any tips on what I should do?  Right now, I only want an LED to flash, but eventually I want it to send/receive bytes from the Arduino.


Right now, I only want an LED to flash

Then just load the blink sketch.

but eventually I want it to send/receive bytes from the Arduino.

Serial.print(), Serial.write(), Serial.available(), and Serial.read() deserve scrutiny.

I would like it to do it from C++ for Windows

Is that different than C++ for Linux? I don't think so.


I can easily make the Arduino flash using Arduino code or the example sketch.

I am talking about making the Arduino LED flash from C++, not via a sketch.  I want to specify some input pin to receive a flashing signal from C++.

Also, yes I believe Windows is different from Linux in the way that it opens and communicates with ports.  I would assume that a library would have different code to open a port in Windows than a port in Linux.


Communication between Arduino and C# program is a something suprisely easy to do.
Check out this url:



Simple LED control code.

Code: [Select]

// zoomkat 8-6-10 serial I/O string test
// type a 1 or 0 in serial monitor. then send or enter
// for IDE 0019 and later

void setup() {
  pinMode(13, OUTPUT);
  Serial.println("serial blink 0021"); // so I can keep track of what is loaded
  Serial.println("send a 1 to turn LED on");
  Serial.println("send a 0 to turn LED off");

void loop()
  while (Serial.available() > 0){
    char c = Serial.read();
    if (c == '1') digitalWrite(13, HIGH);
    if (c == '0') digitalWrite(13, LOW);

Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0


Thank you senti, you helped me connect the dots.

I finally figured out that I need both a sketch that needs to be uploaded to the Arduino, that will handle Serial communication and act upon that serial communication (i.e. flash an LED when a byte is sent).  From the computer C++ code, I can then send information via Serial to the Arduino.  In my searches, I had always found either Arduino code to receive serial information or C++ code to send serial information separately, but did not understand that you needed both.


More on what you want to do at....


The PC-side code isn't written in C++, but the basic ideas are all there, and many specifics which will help you.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131