using Zigbee with leanardo

Hi all

am trying to build a connection between two
Leonardo Microcontrollers using Zigbee

I've done the net tutorials but it isn't working
with me

is there difference between using uno or Leonardo
and is there something called xbee.begin(9600)

thanks

am trying to build a connection between two
Leonardo Microcontrollers using Zigbee

Using which XBees? How are they connected to the Leonardos? How are the XBees configured?

I've done the net tutorials but it isn't working
with me

Was that the net tutorial on how to dye Easter eggs while wearing a pink tutu and dancing the Maramba? What part of that didn't work? Didn't the eggs come out the right color?

is there difference between using uno or Leonardo

Yes.

and is there something called xbee.begin(9600)

Maybe. Far to many unanswered questions for this one to make any sense by itself.

Using which XBees? How are they connected to the Leonardos? How are the XBees configured?

xbee Series 2, connected directly to the leonardo. they are configured using XCTU.

Was that the net tutorial on how to dye Easter eggs while wearing a pink tutu and dancing the Maramba? What part of that didn't work? Didn't the eggs come out the right color?

it was the hello world;

this is my code in the sender

void setup() {
int i;
for(i=4;i<=7;i++)
pinMode(i, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);

}

void command(char command)
{

Serial.println(command);

}

and this is in the receiver

void setup() {
int i;
for(i=4;i<=7;i++)
pinMode(i, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);

}

if(Serial.available() > 0)
{
command = Serial.read();
}

is there anything else I need to write?

Is that all of your code at both ends ?

this is my code in the sender

Which doesn't even have a loop() function, so it can't possibly compile or run.

and this is in the receiver

Which doesn't even have a loop() function, so it can't possibly compile or run.

xbee Series 2

OK.

connected directly to the leonardo

Using rubber bands? Duct tape? Staples? Hot-melt glue?

they are configured using XCTU.

Oh, really? Imagine that.

Feel free to provide some real code and some useful answers this time.

Is that all of your code at both ends ?

this is the communication part of it.

there are other parts that move the motors

I didn't add them

Using rubber bands? Duct tape? Staples? Hot-melt glue?

in the leonardo board it directly it have a place to place it on it

the code provided is only related to the communication

because it is a long code that deals with controlling sensors and motors

this is the first code
is for a leading car

//Standard PWM DC control
int E1 = 5; //M1 Speed Control
int E2 = 6; //M2 Speed Control
int M1 = 4; //M1 Direction Control
int M2 = 7; //M1 Direction Control
int reading = 869;
int reading2 = 31;
int reading3 = 55;
int state = 0;
int sensorValue1;
int sensorValue2;
int sensorValue3;
int speed1;
int speed2;

void command(char command)
{

Serial.println(command);

}

void setup() {
int i;
for(i=4;i<=7;i++)
pinMode(i, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);

}

// the loop routine runs over and over again forever:
void loop() {

if(state==0)
{
speed1=450;
speed2=450;
}

sensorValue1 = analogRead(A0);
delay(1);

if ( sensorValue1 < reading)
{
speed1=225;
speed2=450;
command('1');
}

sensorValue2 = analogRead(A2);
delay(1);

if ( sensorValue2 < reading3)
{
command('2');
speed1=450;
speed2=225;
}

sensorValue3 = analogRead(A1);
delay(1);

if ( sensorValue3 < reading2)
{
command('3');
speed1=0;
speed2=0;
state=1;
}

// read the input on analog pin 0:
analogWrite (E1,speed1); //PWM Speed Control
digitalWrite(M1,HIGH);
analogWrite (E2,speed2);
digitalWrite(M2,HIGH);
delay(7);

}

and this is the 2nd code for the following car

//Standard PWM DC control
int E1 = 5; //M1 Speed Control
int E2 = 6; //M2 Speed Control
int M1 = 4; //M1 Direction Control
int M2 = 7; //M1 Direction Control
int state = 0;
int speed1;
int speed2;
int command;

void setup() {
int i;
for(i=4;i<=7;i++)
pinMode(i, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);

}

// the loop routine runs over and over again forever:
void loop() {

if(Serial.available() > 0)
{
command = Serial.read();
}

if(state == 0)
{
speed1=450;
speed2=450;
}

if ( command == '1' )
{
speed1=225;
speed2=450;
}

if ( command == '2' )
{
speed1=450;
speed2=225;
}

if ( command == '3' )
{
speed1=0;
speed2=0;
state=1;
}

// read the input on analog pin 0:
analogWrite (E1,speed1); //PWM Speed Control
digitalWrite(M1,HIGH);
analogWrite (E2,speed2);
digitalWrite(M2,HIGH);
delay(1);

}

this is the communication part of it.

there are other parts that move the motors

I didn't add them

You should have.

in the leonardo board it directly it have a place to place it on it

No, it does not. Only the FIO has XBee headers built in. All other OFFICIAL models need a shield or some kind of breakout board.

If you have a clone, you should says so UP FRONT.

the code provided is only related to the communication

because it is a long code that deals with controlling sensors and motors

Well, get rid of the crap that deals with sensors and motors until you get the communication working.

You still haven't said HOW you configured the XBees.

Your shift key is still not being used.

If you have a clone, you should says so UP FRONT.

that what they say

That is not a Leonardo. It is a Leonardo clone with extra hardware.

The major difference between the UNO and the Leonardo is that on the UNO pins 0 and 1 are connected to the Serial instance, while on the Leonardo, they are connected to the Serial1 instance. On the UNO, Serial is also connected to the USB interface. On the Leonardo, Serial is connected to the USB interface.

So, it the XBee were connected, via a shield, to a UNO, via the hardware serial pins, and you wanted to read from the XBee and write to the Serial Monitor, you'd use Serial.read() and Serial.print().

If the XBee were connected, via a shield, to a real Leonardo, , via the hardware serial pins, and you wanted to read from the XBee and write to the Serial Monitor, you'd use Serial1.read() and Serial.print().

I don't know, on your clone, where the XBee is connected. You might have luck reading data from it, assuming that it is properly configured, using Serial1.read() instead of Serial.read(), and you might have luck sending data to it using Serial1.print() instead of Serial.print().

I use it it still not working. but maybe it is because
of the configuration

I followed this video

Did the XBee communication work when you tried the serial communication without the Arduinos ?

it works with the Helllo world example
but in the inverse way