int inputPin = D1; // choose the input pin (for PIR sensor)
int ledPin = D0; // LED Pin
int piezo = D2; // Piezo pin
int val = 0; // variable for reading the pin status
void setup()
{
pinMode( ledPin, OUTPUT );
pinMode( inputPin, INPUT ); // declare sensor as input
pinMode( piezo, OUTPUT );
}
void loop()
{
val = digitalRead(inputPin);
if (val == HIGH){
//digitalWrite(piezo, HIGH);
digitalWrite(ledPin, HIGH);
delay(1000);
tone(piezo, 2551, 2000);
Particle.publish("Intruder")
}
digitalWrite(ledPin, LOW);
delay (2000);
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .