Pages: [1]   Go Down
Author Topic: how to use "mills" in my code?  (Read 489 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi im wondering how do i use this mills in my sketch,i have the 3 door alarm..when they
are opened they trigger and led,but i cant really figure out how to also add the pir sensor so when
somone walks into the room another led turns on.
i have tried this why but havent been able to figure it out....is the arduino able to watch the 3 doors and watch the pir at the same time? thanks smiley-draw

int door1 = 2; //front door
int door2 = 3;  //back door
int door3 = 4;  //porch door
int led1  = 13;


void setup()
{
  pinMode(door1,INPUT);
  pinMode(door2,INPUT);
  pinMode(led1,OUTPUT);

}

void loop()
{
  if (digitalRead(door1) == HIGH || (digitalRead(door2)== HIGH))
  {
    digitalWrite(led1,LOW);
    millis(500);
    digitalWrite(led1,HIGH);
    millis(500);

    {
      int motion1 = 5;
      pinMode(motion1,INPUT);
      if (digitalRead(motion1)== HIGH)
      {
        digitalWrite(led1,HIGH);
      }

      else

      {
        digitalWrite(led1,LOW);
      }
    }
  }





  else
  {
    digitalWrite(led1,LOW);
  }
}


Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 611
Posts: 49092
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Look at the blink without delay example. You are currently not even close. millis() is NOT a direct replacement for delay().
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ha ha ok thanks
Logged

East Anglia (UK)
Online Online
Faraday Member
**
Karma: 114
Posts: 4247
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not part of your problem or the solution but
Code:
      int motion1 = 5;
      pinMode(motion1,INPUT);
does not really belong in the loop() function
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok i was just trying differnt ways
Logged

Pages: [1]   Go Up
Jump to: