help with two pir's code?


hi have 2 pir sensors , 2 rooms,i want put 1 pir in each room,and have on light in room when mothin detected,i got 1 room work,but im having little trouble adding code other 1 possible on arduino?
this works rite now....

int room1 = 2;
int room2 = 3;
int motionroom1 = 7;
int motionroom2 = 8;

void setup()
{
  pinmode(motionroom1,input);
  pinmode(room1,output);
  pinmode(room2,output);
//--------------vtest--------------------------------//
  digitalwrite(room2,high);
 
  digitalwrite(room1,low);
  delay(500);
  digitalwrite(room1,high);
  delay(500);
  digitalwrite(room2,low);
  delay(500);
  digitalwrite(room2,high);
  delay(500);

digitalwrite(room1,low);
digitalwrite(room2,low);
delay(4000);
digitalwrite(room1,high);
digitalwrite(room1,high);
delay(4000);
}
//--------------------end test------------------------------------
void loop()
{
  if (digitalread(motionroom1) == high)
  {
    digitalwrite(room1,low);
    delay(250000);
    digitalwrite(room1,high);
  }
}

code: [select]
int motionroom1 = 7;
int motionroom2 = 8;

void setup()
{
  pinmode(motionroom1,input);
  pinmode(room1,output);
  pinmode(room2,output);

why isn't motionroom2 declared input pin?

code: [select]
void loop()
{
  if (digitalread(motionroom1) == high)
  {
    digitalwrite(room1,low);
    delay(250000);
    digitalwrite(room1,high);
  }
}

don't think necessary read other sensor? motion in other room won't detected more 6 minutes if there motion on first room.

my crystal ball tells me study of blink without delay example in future.


Arduino Forum > Using Arduino > Programming Questions > help with two pir's code?


arduino

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62