I have to give this one more try, as you can see, I am not that good telling you people what I want in words. Here We Go.
The first program, I have with the (one Arduino,two ping sensor's,two resistor's and led's). The program works great.
What I need your help is with, making all this wireless, with two xbee's.
Here is the set-up. == (Arduino,xbee,ping,resister and led) (ping,xbee,resister and led)
I want to make the xbee's do line passing, I do have that working.
Maybe Serial data world work to.
I am trying to save on the battery power, So I think line passing with xbee's is the best.
On the sec. program I have my program, On this program,
I am using two Arduino's. I tried line passing with the xbee's.
Here is the Set-up. Box1== (Arduino,xbee,ping,and resistor and led) and
Box2== (Arduino,xbee,ping,and resistor and led).
It needs help with code, because I don't know how to get line (else if (XbeeOutPin && (XbeeInPin,INPUT);//I can't get this line to work, needs some help?)
(((((First)))))))
#define trigPin 13
#define echoPin 12
#define trigPins 3
#define echoPins 2
#define led 7
#define ledd 8
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(trigPins, OUTPUT);
pinMode(echoPins, INPUT);
pinMode(led, OUTPUT);
pinMode(ledd, OUTPUT);
}
void loop() {
long duration, distance;
digitalWrite(trigPin, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin, HIGH);
// delayMicroseconds(1000); - Removed this line
delayMicroseconds(10); // Added this line
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
long durations, distances;
digitalWrite(trigPins, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPins, HIGH);
// delayMicroseconds(1000); - Removed this line
delayMicroseconds(10); // Added this line
digitalWrite(trigPins, LOW);
durations = pulseIn(echoPins, HIGH);
distances = (durations/2) / 29.1;
if (distance >= 200 || distance <= 0)
{
Serial.println("Out of range");
}
else if(distances >= 200 || distances <= 0)
{
Serial.println("Out of range");
}
else
{
Serial.print(distance);
Serial.println(" cm");
Serial.print(distances);
Serial.println(" cm");
}
if (distances < 30 && distance < 30)
{
digitalWrite(led, HIGH);
digitalWrite(ledd, HIGH);
}
else
{
digitalWrite(led,LOW);
digitalWrite(ledd,LOW);
}
delay(50);
}
((((((Sec)))))))
#define trigPin 12
#define echoPin 13
#define LedPin 2
#define XbeeInPin 3
#define XbeeOutPin 4
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(LedPin,OUTPUT);
pinMode(XbeeInPin,INPUT);
pinMode(XbeeOutPin,OUTPUT);
}
void loop() {
int duration, distance;
digitalWrite(trigPin, HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance >= 200 || distance <= 0){
Serial.println("Out of range");
}
else {
Serial.print(distance);
Serial.println(" cm");
}
if (distance < 10);
{
digitalWrite(XbeeOutPin,HIGH);
}
else if (XbeeOutPin && (XbeeInPin,INPUT);//I can't get this
// line to work, needs some help?
{
digitalWrite (LedPin,HIGH);
}
else
{
digitalWrite (LedPin,Low);
delay(500);
}