Go Down

Topic: Motion Control (Read 480 times) previous topic - next topic

hemant

Need some's help  Thanks

in the  code I want to add
if the motion is detecde again  within 40 sec HIGH pin 12
if the motion is detected again after 70 sec HIGH pin 8

second sensor
motion detected by second motion sensor
&
if the motion is detecde two times within a min  HIGH pin 7
if the motion is detected four times HIGH pin 8

(http://littlebirdelectronics.com/products/electronic-brick-pir-motion-sensordigital
                             Electronic Brick - PIR Motion Sensor(Digital) SS-ELB106C5M-X)

MY CODE

  int ledPin =  13;    // LED pin
  int motionPinfront = 2;   // motion detector input pin
  int motionPinrear = 3;   // motion detector input pin
  int senseMotion = 0;       // variable to hold current state of motion detector
  int timer = 500;

void setup() {
   Serial.begin (9600);

  pinMode(ledPin, OUTPUT);     
  pinMode(motionPinfront, INPUT);
   pinMode(motionPinrear, INPUT);
  delay   (2000);                                 
}

void loop()
{
   
    senseMotion = digitalRead(motionPinfront);
    if (senseMotion == HIGH)
{
    blinky();
}
    delay (timer);
     Serial.println (senseMotion);
      delay (10);
}

if
{
   
    senseMotion = digitalRead(motionPinrear);
    if (senseMotion == HIGH)
{
    blinky();
}
    delay (timer);
     Serial.println (senseMotion);
      delay (10);

void blinky()
{
  for(int i=0; i<3; i++)/*blinks three times*/
{
    digitalWrite(13,HIGH);
    delay(200);
    digitalWrite(13,LOW);
    delay(200);
  }
}



wildbill

Your code does not compile - there is a closing brace early in loop that puts the code after it outside any function. Also, there is an if soon after with no condition to test. You might want to address those issues first and repost. When you do, please use the code tags '#' button on the toolbar to enclose it so it's more readable

Go Up