Created
June 10, 2019 20:09
-
-
Save MindstormFan/f83b8ce834d4a7d8f39011935025baf2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//www.elegoo.com | |
//2016.12.9 | |
#include "pitches.h" | |
#include <LiquidCrystal.h> | |
int ledPin = 6; // LED on Pin 6 of Arduino | |
int pirPin = 2; // Input for HC-S501 | |
int buzzer = 5;//the pin of the passive buzzer | |
int pirValue; // Place to store read PIR Value | |
int duration = 500; // 500 miliseconds | |
int melody[] = {NOTE_B0, NOTE_DS8}; | |
int interruption = 0; | |
// initialize the library with the numbers of the interface pins | |
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); | |
void setup() { | |
Serial.begin(9600); | |
pinMode(ledPin, OUTPUT); | |
pinMode(pirPin, INPUT); | |
pinMode(buzzer,OUTPUT);//initialize the buzzer pin as an output | |
digitalWrite(ledPin, LOW); | |
// set up the LCD's number of columns and rows: | |
lcd.begin(16, 2); | |
// Print a message to the LCD. | |
lcd.print("Interruptions are: "); | |
} | |
void loop() { | |
pirValue = digitalRead(pirPin); | |
digitalWrite(ledPin, pirValue); | |
Serial.println(pirValue); | |
if(pirValue == 1) { | |
tone(buzzer, melody[0], duration); | |
++interruption; | |
lcd.setCursor(0, 1); | |
lcd.print((int)interruption); | |
delay(6000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment