Tuesday, April 2, 2013

Communication using the Xbee Shield

In our project we have two buses and two bus stops, each having an arduino with a xbee shield.
The arduino at the bus communicates with the arduino at the bus stop. The bus sends the bus number and the stop number to the arduino at the bus stop. The bus stop receives the information which is retrieved by the psuedo server to update the database.


Transmitter code:

void setup()
{
  Serial.begin(9600); 
  Serial.flush();
}

void loop()
{

//transmitting a string that contains the information of the bus number and bus stop number

//receive an acknowledgement from the bus stop.

// transmit new string which is updated for the next bus stop

}

Receiver code:

void setup(){
  Serial.begin(9600);
}

void loop()
{

//receives a string from the bus.

//checks if the bus stop number in the string matches the number of that bus stop

// if matches then sends a string with the updated bus stop number
   else does not send anything.
}