Go Down

Topic: C++ (Read 5004 times) previous topic - next topic

jb3330333

Hello, I'm pretty new to the Arduino world.

I'm using using an arduino uno board and I want to interface it to a Borland C++ program. Basically I want one of the pwm ports to ouput a certain voltage if a variable is one value and another voltage if that variable is another. I wrote the code to do this with the arduino software. So do I upload that code to the board then use the serial.read and serial.write commands?

PaulS

Quote
So do I upload that code to the board then use the serial.read and serial.write commands?

You have the order backwards, but the concept right.

Whatever the PC sends to the serial port, the Arduino reads using Serial.available() and Serial.read(). When the Arduino wants to send some data back, it uses Serial.write(), Serial.print(), and/or Serial.println().

Be sure to read up on the difference between Serial.print and Serial.write(), so you know when to use each one appropriately.

Also, make sure you understand that the Arduino reads one byte/character at a time. If the C++ application sends 27 as a string, the Arduino will read that as '2' and '7', not as the number 27.

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!

Arduino
via Egeo 16
Torino, 10131
Italy