Just Help me with this program, I have the xbee's working, line passing working. AT mode,
has to be programed in the xbee, not the arduino.
I need A line in the code that reads (if (distance > 10) = HIGH == distanceHigh.
distanceHigh needs to be high if it is > 10
distanceHigh needs to be low if it is < 10
This is what I don't know how to program, it may need A distanceHigh = (distance >10)=HIGH)
if (distance > 10);
{
digitalWrite(OutPin,HIGH);
}
else if (distanceHigh && (InPin,INPUT);
#define trigPin 12
#define echoPin 13
#define LedPin 2
#define InPin 3
#define OutPin 4
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(LedPin,OUTPUT);
pinMode(InPin,INPUT);
pinMode(OutPin,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(OutPin,HIGH);
}
else if (OutPin && (InPin,INPUT);
{
digitalWrite (LedPin,HIGH);
}
else
{
digitalWrite (LedPin,Low);
delay(500);
}