This experiment uses infrared sensors to detect if anyone is moving around the sensor. If so, the buzzer will sound an alarm.
Material:
- Arduino
- breadboard
- LED
Note: you can redeem it on PCBWay, please support me and register with this invitation 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 infraredinterface 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 storethe 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 }
Lastly, I recommend watching Anthony's project video.
Comments