0

My groups are trying to connect 3 Arduinos (e.g. A, B, C); connect A and B with Bluetooth connection, connect A and C with wire connection, so A is the master here. We have managed to connect A and B via Bluetooth according to the article you've given, but we couldn't find out how to send data from B to A, so for example, if you press a button from B, allow A to be activated as well. And for connecting A and C, we wanted to connect those two via metal plate contacts, but there is no information about how doing it so we decided to use wire instead of metal contacts. However, if we connect A and C using wire connection, all the buttons on both A and C are disabled (they work somehow if we press the same button for several times). So how can we send data from slave to master so that two circuits can be controlled together at the same time?

Share a link to this question (includes your user id)
| edit | | close | delete |
0

There have been several assignments in which we have send data, eg. practical assignment 2 and recently, assignment 6.

Once there is a connection, you can send data via Serial: eg. if a button is pressed, your can send:

Serial.println("button1");

Then on the other end - the receiver - you can do:

// receive data from Serial connection:
while (Serial.available()>0) {
    char readchar = Serial.read();
    if (readchar>=32 && readchar<127) line += readchar; // if valid character add it to line (ignore/drop invalids chars)
    delay(2);
}
if (line.length() > 1) { // did we receive anything?

    if (line.startsWith("button1")) { // button1 pressed?
        // do something when button1 was pressed
    }

    line = ""; // make line empty to prevent processing the same line twice
}
Share a link to this answer (includes your user id)
| edit | delete |

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.