Attaching PIR sensor with arduino and HC-05.

Do we need a new adaptive operating system?


  • Total voters
    2

Thread Starter

Ujwal Bhagat

Joined Jan 30, 2016
76
Hey guys I'm back with my new project. Devices : Arduino UNO
PIR SENSOR
HC-05
5v Relay
I wanted the setup to be like that, when someone enters the room, PIR sensor sends that information to the arduino, arduino records that information and trigger the relay on and when the PIR sensor get triggered again due to someone who leaves the room or enters the room the PIR sensor sends reports arduino to trigger the relay off.
And also i want the HC-05 module to send the state of relay to my android, and be able to control the relay from my android.
Please do check the attached image. Thanks in advance. 0E9ybM4RW09B5B1f31r4CBrA.jpg
 

Thread Starter

Ujwal Bhagat

Joined Jan 30, 2016
76
I am just asking generally.
You did not provide enough info or any progress you have made so we can help.
I do made some progress, I tried pir sensor code from arduino playground and transmitted motion data to my smartphone, i really wanna combine these programs into one.

I am just asking generally.
You did not provide enough info or any progress you have made so we can help.
I am also trying hard

I am just asking generally.
You did not provide enough info or any progress you have made so we can help.
C:
int calibrationTime = 6;       

//the time when the sensor outputs a low impulse
long unsigned int lowIn;       

//the amount of milliseconds the sensor has to be low
//before we assume all motion has stopped
long unsigned int pause = 5000; 

boolean lockLow = true;
boolean takeLowTime; 

int pirPin = 3;    //the digital pin connected to the PIR sensor's output
int ledPin = 13;


/////////////////////////////
//SETUP
void setup(){
  Serial.begin(115200);
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  digitalWrite(pirPin, LOW);

  //give the sensor some time to calibrate
  Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
      Serial.print(i);
      delay(1000);
      }
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");
    delay(50);
  }

////////////////////////////
//LOOP
void loop(){
int pirPin2 = analogRead(A0);
  // print out the value you read:

     if((pirPin2) > 600){
       digitalWrite(ledPin, HIGH);   //the led visualizes the sensors output pin state
    

       }
else if((pirPin2) < 700){
        digitalWrite(ledPin, HIGH);
}

else
{
Serial.println("You can probably do other better things in your life");
Serial.println(pirPin2);
delay(1000);
}



}
In the loop function, I want to know if i can do, : First when the Pir outputs high value(approx. equal to 698), i want the led high, that is what happening, but when the Pir outputs low value, i want the led high, that is what happening, now comes the tricky part, at this point, Pir is Low, Led is High, Now when the Pir goes high, i want the led Low, this is not happening, CAN ANYONE PLEASE SUGGEST ME SOMETHING?
 
Last edited by a moderator:
Top