pruebaindescifrable&5ñç — Esp32 Devkit C V4 simulation

d

An interactive Esp32 Devkit C V4 circuit simulation you can run free in your browser on Velxio, by figueblue.

Components

Sketch code

#include <Keypad.h>
#include <ESP32Servo.h>
#include <HardwareSerial.h>

// Declaración del puerto serie y objeto para el sensor de huellas
HardwareSerial huellas(2); // Usamos UART2 en el ESP32

const int TX_huella = 16;
const int RX_huella = 17;
Servo puerta;
const int SERVO = 5;
const int pir_motion = 0;
const int buzzer = 4;

const byte FILAS = 4;
const byte COLUMNAS = 4;
char teclas[FILAS][COLUMNAS] = {
  {'1','2','3','A'},   
  {'4','5','6','B'},   
  {'7','8','9','C'},   
  {'*','0','#','D'}    
};
byte pinesFilas[FILAS] = {13, 14, 23, 26};
byte pinesColumnas[COLUMNAS] = {19, 33, 32, 18};

Keypad teclado = Keypad(makeKeymap(teclas), pinesFilas, pinesColumnas, FILAS, COLUMNAS);

String ingresado;
String clave = "159A";
int maximo = clave.length();
int intentos_maximo = 2;
int intentos = 0;

void setup(){
  Serial.begin(115200);
  pinMode(pir_motion, INPUT);
  pinMode(SERVO, OUTPUT);
  pinMode(buzzer, OUTPUT);
  
  huellas.begin(57600, SERIAL_8N1, RX_huella, TX_huella);
  puerta.attach(SERVO);
  puerta.write(0);
}

void buzzer_activado(){
    for(int i = 3; i<3;i++){
        digitalWrite(buzzer, HIGH);
        delay(1000);
        digitalWrite(buzzer, LOW);
        delay(1000);
    }
  
}

void intruso(){
  while(intentos < intentos_maximo){
    while(ingresado.length() < maximo){
      char tecla = teclado.getKey();
      if (tecla) {
        ingresado += tecla;
        Serial.println(ingresado);
       }
    }
    ingresado = "";
    intentos += 1;
  }
  pruebabiometrica();
}

void loop(){
  bool pir_motion_activado = false;
  if(digitalRead(pir_motion) == HIGH && pir_motion_activado == false){
     puerta.write(90);
    intruso();
  }
}

void desbloquearcerradura(){
  puerta.write(0);
}

bool huellaDetectada() {
  if (!huellas.available()) return false;
  while (huellas.available()) huellas.read();
  return true;
}

void pruebabiometrica() {
  if (huellaDetectada()) desbloquearcerradura();

  
}

More projects by figueblue