This experiment use human infrared sensors to detect if anyone is moving around the sensor. If yes the buzzer will make an alarm.
Material:
1. arduino
2. bread board
3. LED
Note: you can redeem it in PCBWay, please support me register by this invited PCBWay link
Here is the connection diagram:
Here is the code:
int Sensor_pin = 3;
int ledpin = 11;
void setup()
{
pinMode(Sensor_pin, INPUT); // Set the human infrared interface as the input state
pinMode(ledpin, OUTPUT);
Serial.begin(9600);
Serial.flush();
Serial.println("Ready");
}
void loop()
{
int val = digitalRead(Sensor_pin); // Define parameters to store the state read by the human infrared senso
if (val == 1) // Buzzer make alarm if someone is detected
{
Serial.println("There is sb moving");
digitalWrite(ledpin, HIGH);
}
else
{
Serial.println("There isn't sb moving");
digitalWrite(ledpin, LOW);
}
delay(100); // Delay 100 milliseconds }