Pages: [1]   Go Down
Author Topic: Serial Communication between 3 arduino  (Read 774 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey all,

I am working on a project that requires 3 separate arduino boards working together passing information back and forth via serial (open to other communication protocols, but I am relatively new to this).  Ultimately they will be wireless.

Set up: 
1 arduino uno (we will call it transmitter ) to transmit analog data (need 20 discreet values to be sent)
1 ardunio mega to receive data from transmitter, as well as be connected to (5) analog sensors, and process and use said data to control digital outputs and send sensor data to the next arduino
1 arduino uno connected to a 16x2 LCD which will be updated with information from the Mega, and provide a menu system that is navigated by "transmitter" (listed above).

 - reason for three arduinos is that each module will be in a different location.

I don't have the code handy to post, but it seems that in configuring the transmitter and mega (connected with wires between serial ports) i can only pass values 0-9, and nothing larger....

Sorry for the ambiguity in this question - ultimately i am reaching out to see if there is any advice for this type of set up, and how to pass more data serially between them.  especially to be able to pass variables or sensor data between the mega and the UNO driving the LCD.

Am I using the wrong data type ? (char, int...?)

FWIW, i have been searching online and through the forums for the last couple of weeks before posting.  Most of the information i have found about preparing data to be sent serially has to do with mapping larger values to a small range, which won't work for this application.

Thanks in advance.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 630
Posts: 49998
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I don't have the code handy to post, but it seems that in configuring the transmitter and mega (connected with wires between serial ports) i can only pass values 0-9, and nothing larger....
Come on back when you do have some code. You are doing something wrong.

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank youl, i'll put it up asap
Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9671
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I don't have the code handy to post, but it seems that in configuring the transmitter and mega (connected with wires between serial ports) i can only pass values 0-9, and nothing larger....

You probably could send the values as bytes up to 255, send the values in a hex format, or send the values as a string. Below is some servo code where the number is sent as a string of characters and then the character string is converted into a number.

Code:
// zoomkat 10-14-11 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// for IDE 0022 and later
// Powering a servo from the arduino usually DOES NOT WORK.

String readString;
#include <Servo.h>
Servo myservo;  // create servo object to control a servo

void setup() {
  Serial.begin(9600);
  myservo.writeMicroseconds(2000); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control
  Serial.println("servo-test-22"); // so I can keep track of what is loaded
}

void loop() {
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  // allow buffer to fill with next character
    }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string
    myservo.writeMicroseconds(readString.toInt()); //convert readString to number for servo
    //myservo.write(readString.toInt()); //for degees 0-180
    readString=""; //empty for next input
  }
}
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you all for your replies..   I found that it works up to 255 with a Serial.print(value, BYTE) command.

Logged

Pages: [1]   Go Up
Jump to: