Baud

I have a project which required sending via Bluetooth data from a GPS device. I am planning to have one communicate via the regular “Serial” port and the other via a Software Serial.

The instructions on the GPS (actually from examples) set the baud rate to 4800. Bluetooth examples set baudrate to 9600.

Would a problem arise using these two different baud rates on two different serial connections? My understanding of baud rate is limited (I’m a newbie :P), and what exactly is it?

If I could use the two rates, would I have to “(Serial/mySerial).begin(XXXX)” every time I try receiving/sending stuff?

This sample code of mine hopefully clears up any ambiguities:

#include <SoftwareSerial.h>
#include <Servo.h> 
#include <Float.h>
#define rxPin 2
#define txPin 3
#define ledPin 13

int turnPos = 45; //Turning Position
Servo myservo;
char GPSString;
int count = 0;
float shouldAngleDirection, angleDirection;
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

void setup() {
  Serial.begin(4800);
  mySerial.begin(9600);
  myservo.attach(9);
}

void loop() {
  printSensorData();
  updateDirection();
  digitalWrite(13, HIGH);
}

void updateDirection(){ 
  shouldAngleDirection = (float) mySerial.read();
  while(shouldAngleDirection!=angleDirection){
    myservo.write(turnPos); 
  }
  myservo.write(0);
}

void printSensorData(){
  if(Serial.available()){
    digitalWrite(13, LOW);
    GPSString = (char)Serial.read();
    if(GPSString=='A'){
      count = 9000;
    }
    Serial.print(GPSString);
    if(count==9032){
      angleDirection = (float)Serial.read();
    }
    if(count==9048){
      Serial.print(","+analogRead(A0));
      count=0;
    }
    count++;
  }
}

Baud rate is the rate at which the signal changes. In our case the signal change indicates one bit so it's the same as bit rate. The serial port needs to know the rate so it can sample the data at the right times. Read the wikipedia article on asynchronous serial communication: http://en.wikipedia.org/wiki/Asynchronous_serial_communication

You only call the begin() function once for each serial port you are using.

As long as the two ports are separate they can be running at different rates.