Summer Sale: 5% OFF Over $49, Code: Elephant5; 10% OFF Over $99, Code:Elephant10



Arduino Project: Making Your Body An Alarm Clock

Posted by Fiona Su on

thumb

Introduction:
PIR motion sensors are used to detect motion from pets/humanoids. In this project, we will create an alarm system to detect motion, combining usage of PIR, I2C 1602 LCD and LED.

Hardware required:

  • Arduino Board *1
  • USB Cable *1
  • I2C 1602 LCD *1
  • PIR Motion Sensor*1
  • Red M5 LED*1
  • 220Ω Resistor *1
  • Breadboard *1
  • Breadboard Jumper Wires
  • Male to Female Dupont Line

Connection Diagram:
Connection for REV4:

thumb

Connection for 2560 R3:
thumb
Sample program:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
byte sensorPin = 6;
byte indicator = 10;
void setup()
{
  lcd.init();                      // initialize the lcd 
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  pinMode(sensorPin,INPUT);
  pinMode(indicator,OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  byte state = digitalRead(sensorPin);
  digitalWrite(indicator,state);
  if(state == 1)
  {
  lcd.setCursor(2,0);
  lcd.print("Somebody is");
  lcd.setCursor(2,1);
  lcd.print("in this area!");
  }
  else if(state == 0)
  {
  lcd.setCursor(2,0);
  lcd.print("No one!      ");
  lcd.setCursor(2,1);
  lcd.print("No one!      ");
  delay(500);
  }
}

Result:
After connection and uploading codes, if the LCD shows ”Somebody is in this area!” and LED lights up, it is reminding of you that somebody is here. Then, if there is no one, it will tell you by displaying “No one!”on LCD and LED off.

thumb 

0 comments

Leave a comment

Please note, comments must be approved before they are published