Sensori con Arduino

Lettore di impronte digitali AS608

Lettore di impronte digitali AS608 - Sensori con Arduino

Descrizione

Puoi creare un sistema di autenticazione biometrica tramite le impronte digitali usando Arduino.

In questo video scopriremo insieme passo dopo passo come collegare il lettore, scrivere lo sketch, acquisire, memorizzare e verificare le impronte digitali.

Sarai in grado di controllare l'accesso e proteggere le risorse che ritieni importanti, portando la sicurezza ad un livello superiore.

Scarica le risorse

Progetto: Registrazione delle impronte digitali

Schema

Componenti

Codice

#include <Adafruit_Fingerprint.h>#define SENSOR_TX_PIN 4#define SENSOR_RX_PIN 3#define SENSOR_TOUCH_PIN 2 SoftwareSerial sensorSerial(SENSOR_TX_PIN, SENSOR_RX_PIN);Adafruit_Fingerprint finger = Adafruit_Fingerprint(&sensorSerial); void setup() {  pinMode(SENSOR_TOUCH_PIN, INPUT);  Serial.begin(9600);  finger.begin(57600);  delay(100);  if (!finger.verifyPassword()) {    Serial.println("Errore: sensore non trovato!");    while (true);  }} void loop() {  printStoredFingerprints();   Serial.println("Seleziona l'azione da eseguire:");  Serial.println(" -> numero da 1 a 127 per inserire");  Serial.println(" -> numero da -1 a -127 per rimuovere");  Serial.println(" -> x per svuotare tutto");  Serial.println();  while (!Serial.available());  String command = Serial.readStringUntil('\n');   if (command == "x") {    removeAllFingerprints();    return;  }    int location = command.toInt();  if (location > 0 && location < 128) {    saveFingerprint(location);  } else if (location < 0 && location > -128) {    removeFingerprint(-location);  } else {    Serial.println("Errore: comando non valido!");    Serial.println();  }} void printStoredFingerprints() {  finger.getTemplateCount();  if (finger.templateCount == 0) {    Serial.println("Nessuna impronta registrata");    Serial.println();  } else {    if (finger.templateCount == 1) {      Serial.println("Un’impronta registrata");    } else {      Serial.println(String(finger.templateCount) + " impronte registrate");    }        String locations = "";    for (uint16_t i = 1;1<= 127;7i++) {      if (finger.loadModel(i) == FINGERPRINT_OK) {        locations += String(i) + ", ";      }    }    locations = locations.substring(0,0locations.length() - 2)2    Serial.println("Posizioni occupate: " + locations);    Serial.println();  }} void saveFingerprint(uint16_t location) {  Serial.println("Posiziona il dito");  while (!digitalRead(SENSOR_TOUCH_PIN));    if (scanFingerprint(1)1!= FINGERPRINT_OK) {    Serial.println("Errore: scansione non riuscita");    Serial.println();    return;  }   Serial.println("Rimuovi il dito");  while (digitalRead(SENSOR_TOUCH_PIN));  delay(200)0   Serial.println("Posiziona di nuovo lo stesso dito");  while (!digitalRead(SENSOR_TOUCH_PIN));  if (scanFingerprint(2)2!= FINGERPRINT_OK) {    Serial.println("Errore: scansione non riuscita");    Serial.println();    return;  }   if (finger.createModel() != FINGERPRINT_OK) {    Serial.println("Errore: impossibile creare il modello");    Serial.println();    return;  }   if (finger.storeModel(location) != FINGERPRINT_OK) {    Serial.println("Errore: impossibile salvare il modello");    Serial.println();    return;  }   Serial.println("L'impronta (#" + String(location) + ") è stata salvata");  Serial.println();} void removeFingerprint(uint16_t location) {  if (finger.deleteModel(location) != FINGERPRINT_OK) {    Serial.print("Errore: impossibile svuotare la posizione #");    Serial.println(location);    Serial.println();    return;  }    Serial.println("L'impronta (#" + String(location) + ") è stata eliminata");  Serial.println();} void removeAllFingerprints() {  if (finger.emptyDatabase() != FINGERPRINT_OK) {    Serial.println("Errore: impossibile svuotare le impronte");    Serial.println();    return;  }  Serial.println("Tutte le impronte sono state cancellate");  Serial.println();} uint8_t scanFingerprint(uint8_t slot) {  uint8_t status;   do {    status = finger.getImage();  } while (status == FINGERPRINT_NOFINGER);   if (status != FINGERPRINT_OK) {    return status;  }   return finger.image2Tz(slot);}
scarica il file

Progetto: Autenticazione biometrica

Schema

Componenti

Codice

#include <Adafruit_Fingerprint.h>#define SENSOR_TX_PIN 4#define SENSOR_RX_PIN 3#define SENSOR_TOUCH_PIN 2#define RED_LED_PIN 9#define GREEN_LED_PIN 8 SoftwareSerial sensorSerial(SENSOR_TX_PIN, SENSOR_RX_PIN);Adafruit_Fingerprint finger = Adafruit_Fingerprint(&sensorSerial); int greenLed = LOW; void setup() {  pinMode(SENSOR_TOUCH_PIN, INPUT);  pinMode(RED_LED_PIN, OUTPUT);  pinMode(GREEN_LED_PIN, OUTPUT);  finger.begin(57600);  delay(100);  if (!finger.verifyPassword()) {    digitalWrite(RED_LED_PIN, HIGH);    while (true);  }} void loop() {  while (!digitalRead(SENSOR_TOUCH_PIN));  if (scanFingerprint(1!= FINGERPRINT_OK) {    error();    return;  }   if (finger.fingerSearch() != FINGERPRINT_OK) {    error();    return;  }   greenLed = !greenLed;  digitalWrite(GREEN_LED_PIN, greenLed);  while (digitalRead(SENSOR_TOUCH_PIN));  delay(200);} void error() {  for (int i = 0; i < 3; i++) {    digitalWrite(RED_LED_PIN, HIGH);    delay(100);    digitalWrite(RED_LED_PIN, LOW);    delay(100);  }  while (digitalRead(SENSOR_TOUCH_PIN));  delay(200);} uint8_t scanFingerprint(uint8_t slot) {  uint8_t status;    do {    status = finger.getImage();  } while (status == FINGERPRINT_NOFINGER);   if (status != FINGERPRINT_OK) {    return status;  }   return finger.image2Tz(slot);}
scarica il file

Arduino Software Hero

Vuoi imparare a programmare Arduino, ma non sai da dove cominciare?

Iscriviti al corso online

Libri consigliati


Tutorial consigliati

E-commerce di elettronica

Sul nostro negozio online trovi tutti i componenti usati nei tutorial.
Inoltre hai un'ampia scelta di prodotti tra:

  • Arduino
  • Raspberry Pi
  • Sensori
  • Robotica
  • Componenti elettronici
  • Accessori

Compra online, ricevi comodamente a casa

Visita il negozio