Home‎ > ‎

megapir


int pirpin = 51;
int powerpin = 53;
int led = 13;
int count = 0;
int soundpin = 41;
void setup()
{
  pinMode(powerpin, OUTPUT);
  pinMode(led, OUTPUT);
  pinMode(pirpin, INPUT);
  pinMode(soundpin, OUTPUT);
  Serial.begin(9600);
  digitalWrite(powerpin, HIGH);
 

  delay(5000);
}
void loop()
{
  int readin ;
   readin = digitalRead(pirpin);
   
  if(readin == HIGH)
  {
  digitalWrite(led, HIGH);
  Serial.println("motion");
  tone(soundpin, 1700);
  delay(50);
  }
  else
  {
    Serial.println("no motion");
  digitalWrite(led, LOW);
  noTone(soundpin);
  }
}
Comments