Pages: [1]   Go Down
Author Topic: arduino communicate with C++ (code blocks)  (Read 705 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



I have an Arduino and I would like to communicate with my computer. I would like to use usb (COM3) ( I think it is the easiest way). I use C++ ( Code Blocks) on my computer. I wan't to send an variable from computer to my arduino.

I've written the Arduino code:

// receiver
int data;

void setup() {
    Serial.begin(9600);
    pinMode (13, OUTPUT);
}

void loop() {
    if (Serial.available()) {
        data = Serial.read();
        if (data==1){
            digitalWrite(13, HIGH);
            delay(100);
        }
    }
    digitalWrite(13, LOW);
}

I want to write the sender code in C++ ( Code Blocks) which send an variable (data=1) .

Can you help me?
Logged

Padova, Italy
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think you need to import the serial library.
Read here: it could help you.. http://stackoverflow.com/questions/11677639/two-way-c-communication-over-serial-connection

smiley-wink
Logged

Pages: [1]   Go Up
Jump to: