Help with in & out Sensors


hi
i'm working on project uses 2 sensors (pir motion sensors)
i want install them in way if first sensors signals second led work.
if other way around led work
here's code i'm using :

code: [select]
int sensor1=0;
int sensor2=0;
void setup() {
pinmode(8, output);
pinmode(9, output);
pinmode(7, input);
pinmode(6, input);
}
void loop() {
  sensor1 = digitalread(6);
  sensor2 = digitalread(7);
  if(sensor1 == high){
    if(sensor2 == high){
      digitalwrite(8,high);
      delay(1500);
      digitalwrite(8,low);
    }
  }
  else if (sensor2 == high){
    if (sensor1 == high){
      digitalwrite(9,high);
      delay(1500);
      digitalwrite(9,low);
    }
  }
}


however first condition works , other way doesn't
can find problem ?

look @ tests.  either of them true if both inputs triggered.

one way grab value of millis() when either sensor triggered , use 2 values determine happened first.


Arduino Forum > Using Arduino > Programming Questions > Help with in & out Sensors


arduino

Comments