CR555Andrea PriviteraGabriele Pulvirenti
Published

Access control for school laboratories

We want to control access to laboratories, allowing entry only to authorized people and keeping information on entry and exit events.

BeginnerFull instructions provided3 hours44
Access control for school laboratories

Things used in this project

Hardware components

UNIHIKER K10 AI Educational Tool for Kids (Image Detection, Voice Recognition, TinyML)
DFRobot UNIHIKER K10 AI Educational Tool for Kids (Image Detection, Voice Recognition, TinyML)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1

Software apps and online services

DFRobot mind+

Story

Read more

Schematics

Schematics

Only an Unihiker K10 and a servo motor

Code

Code

Arduino
The code of this project
#include <Arduino.h>
#include <unihiker_K10.h>
#include <DFRobot_Servo.h>

// ================== COMPONENTI K10 ==================
DFRobot_K10 display;
DFRobot_K10_Camera camera;
DFRobot_K10_FaceRecognition faceRecognition;

Servo servo_caveau;

// ================== PIN ==================
#define SERVO_PIN 0
#define BUZZER_PIN 10

// ================== FUNZIONI PORTA ==================
void apriPorta() {
  servo_caveau.angle(90); // aperto
}

void chiudiPorta() {
  servo_caveau.angle(0); // chiuso
}

// ================== ALLARME ==================
void attivaAllarme() {
  for (int i = 0; i < 5; i++) {
    digitalWrite(BUZZER_PIN, HIGH);
    delay(200);
    digitalWrite(BUZZER_PIN, LOW);
    delay(200);
  }
}

// ================== MESSAGGI ==================
void benvenuto(String nome) {
  display.fillScreen(COLOR_WHITE);
  display.setTextColor(COLOR_GREEN);
  display.setTextSize(3);
  display.drawString(20, 80, "BENVENUTO");
  display.drawString(20, 130, nome);

  apriPorta();
  delay(5000);
  chiudiPorta();
}

void rifiutato() {
  display.fillScreen(COLOR_WHITE);
  display.setTextColor(COLOR_RED);
  display.setTextSize(3);
  display.drawString(10, 100, "VOLTO");
  display.drawString(10, 150, "NON RICONOSCIUTO");

  chiudiPorta();
  attivaAllarme();
}

// ================== SETUP ==================
void setup() {
  pinMode(BUZZER_PIN, OUTPUT);

  servo_caveau.attach(SERVO_PIN);
  chiudiPorta();

  display.begin();
  display.initScreen();
  display.creatCanvas();
  camera.begin();

  // REGISTRAZIONE VOLTI
  faceRecognition.addFace("Mario");
  faceRecognition.addFace("Luca");
  faceRecognition.addFace("Anna");
}

// ================== LOOP ==================
void loop() {
  String volto = faceRecognition.recognize();
  if (volto == "Mario") {
    benvenuto("Mario");
    }
    else if (volto == "Luca") {
      benvenuto("Luca");
    }
    else if (volto == "Anna") {
  benvenuto("Anna");
  }
  else if (volto != "" && volto != "No Face") {
    rifiutato();
  }

  delay(500);
}

Credits

CR555
8 projects • 13 followers
Andrea Privitera
1 project • 0 followers
Gabriele Pulvirenti
1 project • 0 followers

Comments