Things used in this project

Hardware components:
A000066 iso both
Arduino Arduino UNO & Genuino UNO
×1
Bread board b23zpsd8ys
PHPoC PHPoC Bread Board
×1
09590 01
LED (generic)
×2
Mfr 25fbf52 221r sml
Resistor 221 ohm
×2
51gzz5eu9pl. sx425
HC-SR04
×1
Adafruit industries ada1536 image
Buzzer
×1
RC522 Card Reader
×1
Real Time Clock
×1
Software apps and online services:
Ide web
Arduino Arduino IDE

Schematics

Schematics with Fritzing
allarme_ultrasuoni_e_ora_pEiHvFbWpj.fzz
Schematics with Fritzing
Allarme ultrasuoni e ora iguzqrvwry

Code

Very compact alarmC/C++
It is an alarm that capture any movement in front of it
#include <RFID.h>
#include <SPI.h>
#include <SR04.h>
#include <DS3231.h>
#include <Wire.h>
String ora;
String mins;
String orario;
DS3231 Clock;

#define ECHO_PIN 3
#define TRIG_PIN 4
#define green 5
#define red 6
#define buzz 8
#define RESET_DIO 9
#define SDA_DIO 10

#define delayRead 600

SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN);
RFID RC522(SDA_DIO, RESET_DIO); 

bool h12;
bool PM;
int attivo=false; 
int statoattivato=0;
String codiceLetto;
String codiceAutorizzato = "5545A93980";

void setup(){ 
  Wire.begin();
  SPI.begin(); 
  RC522.init();
  pinMode(buzz,OUTPUT);
  pinMode(red,OUTPUT);
  pinMode(green,OUTPUT);
  digitalWrite(green,LOW);
  digitalWrite(red,HIGH);
}
 
void loop(){
  ora=Clock.getHour(h12, PM), DEC;
  mins=Clock.getMinute(), DEC;
  orario=ora+":"+mins;
  byte i;
  if (RC522.isCard()) {   
    if(verificaCodice(lettura())) {
      rilevatore();
    }
    delay(delayRead);
  }
  if (orario=="21:56" && statoattivato==0) {
    statoattivato=1;
    rilevatore();
  }
}

void rilevatore() {
  if (attivo==false) {
    attivo=true;
    digitalWrite(red,LOW);
    digitalWrite(green,HIGH);
    while (attivo=true) {
      if (sr04.Distance()<120) 
        tone(8,262,500);
      if (RC522.isCard()) {
        if (verificaCodice(lettura())) {
          attivo=false;
          digitalWrite(green,LOW);
          digitalWrite(red,HIGH);
          break;
        }     
      }
    }
  }
}

boolean verificaCodice(String codiceLetto){
  if(codiceLetto.equals(codiceAutorizzato)){
    return true;
  }
  else{
    return false;
  }
}


String lettura(){
  byte i;
  RC522.readCardSerial();
  String codiceLetto ="";
  for(i = 0; i <= 4; i++) {
    codiceLetto += String (RC522.serNum[i],HEX);
    codiceLetto.toUpperCase();
    }
  return codiceLetto;
}

Credits

Icona canale ulrv1z1uga
Simone Adobs

Hi, Hackster Community! I'm Simone Adobs and I am an Arduino fan. Take a look to all my projects! ;-)

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

PHPoC- Web-based Joystick
Easy
  • 8
  • 4

Full instructions

This project shows how to control devices from anywhere using web-based joystick on smart phone and PHPoC

Arduino - Web-based Joystick
Easy
  • 15
  • 4

Full instructions

This project shows how to control devices from anywhere using web-based joystick on smart phone

PHPoC: Web-Based Thermometer
Easy
  • 208
  • 11

Full instructions

This project allows you to check the temperature at home from anywhere using a web browser.

Distance Indicator Using Ultrasonic Sensor
Easy
  • 35
  • 3

Work in progress

This project lights a set of LED's depending upon the distance of the obstacle with respect to the ultrasonic sensor.

BluSpike - Community Driven BLE Sensor Network
Easy
  • 30
  • 2

Full instructions

Easy to build w/ off the shelf parts, BLE solar powered sensor array. Connect and share its data to the cloud and be rewarded with ethereum

PHPoC - Web-Based MP3 Player
Easy
  • 202
  • 9

This project shows how to control MP3 player via webpage using PHPoC.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login