Translate

Kendali Palang Pintu Otomatis Berbasis Fingerprint Sensor Arduino + Bascom avr

Kendali Palang Pintu Otomatis Berbasis Fingerprint Sensor Arduino + Bascom avr


        Pada Penjelasan kali ini akan dibahas mengenai bagaimana cara membuat sebuah alat yang digunakan untuk mengendalikan palang pintu secara otomatis menggunakan sensor fingerprint atau sensor sidik jari, pada alat ini terdapat 2 buah palang pintu yaitu untuk masuk dan keluar jadi programnya juga ada dua. buka-tutup palang pintu menggunakan mikro servo dan untuk processornya menggunakan ATMega8. programnya menggunakan auto-reset atau watchdog timer. untuk lebih jelasnya berikut adalah program dan skemanya.




a. Skema Minimum System





b. Sensor Fingerprint





b. Mini Servo





c. Laser dan Sensor Photodioda






d. LCD 16x4






e. Program Bascom AVR

$regfile = "m8def.dat"
$crystal = 16000000
$baud = 9600

Config Lcdpin = Pin , Rs = Portd.4 , E = Portd.5 , Db4 = Portd.6
Config Lcdpin = Pin , Db5 = Portd.7 , Db6 = Portb.0 , Db7 = Portb.1
Config Lcd = 16 * 4
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Watchdog = 2048


Dim Data_masuk As String * 100
Dim Cmti_pos As Byte , Cmgr_pos As Byte , Index_pos As Byte , Cmd_pos As Byte
Dim Pjg_sms_index As Byte , Pjg_data As Byte
Dim Sms_index As String * 3
Dim Cmd As String * 5
Dim Cmdbin As Byte
Dim Dataadc As Word
Dim Mark As Integer
Dim Count As Integer

Mark = 0
Cls

Ddrb.2 = 1
Ddrd.3 = 1
Portd.3 = 1

Cls
Cursor Off



Mulai:
Enable Interrupts
'
Start Adc


Data_masuk = " "

Cls


Do

If Mark = 1 Then
Config Servos = 1 , Servo1 = Portb.2 , Reload = 10
Config Portb.2 = Output

Servo(1) = 65
Wait 5

Servo(1) = 135


Do

'Locate 1 , 1
'Lcd "TEKAN RESET"

'auto reset tiap 2 detik
Start Watchdog

Loop
End If


If Mark = 0 Then

On Urxc Getchar

Enable Urxc


Do
Dataadc = Getadc(0)

Locate 1 , 1
Lcd "Kendaraan Keluar"
Locate 2 , 1
Lcd "Silahkan Letakan"
Locate 3 , 1
Lcd "Jari Anda"
'Lcd Dataadc

Waitms 200

If Dataadc >= 1020 Then
Count = 10
Do


Decr Count

If Count < 1 Then
Count = 0
End If

Locate 4 , 1
Lcd "Sisa Waktu= " ; Count

If Count = 0 Then
Portd.3 = 0
End If


Wait 1

Loop
End If

Loop
End If

Loop


Getchar:

Cls

   Input Data_masuk

   Upperline
   Lcd "DATA MASUK"

   Pjg_data = Len(data_masuk)

   Cmti_pos = Instr(data_masuk , "ID")

   Cmd_pos = Instr(data_masuk , "#")

   If Cmd_pos <> 0 Then
      Incr Cmd_pos
      Cmd = Mid(data_masuk , Cmd_pos , 1)

      Portd.3 = 1

      Locate 2 , 1
      Lcd "ID = " ; Cmd

      Select Case Cmd
      Case "0" :
      Locate 3 , 1
      Lcd "Eko Prawiro"
      Mark = 1
      Wait 3

      Disable Urxc
      Goto Mulai

      Case "1" :
      Locate 3 , 1
      Lcd "Marta Cihuy"
      Mark = 1
      Wait 3

      Disable Urxc
      Goto Mulai

      End Select

   End If

Return





f. Program Arduino IDE

#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>

int getFingerprintIDez();

// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
SoftwareSerial mySerial(2, 3);


Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup() 
{
  Serial.begin(9600);
  Serial.println("fingertest");

  // set the data rate for the sensor serial port
  finger.begin(57600);
 
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1);
  }
  Serial.println("Waiting for valid finger...");
}

void loop()                     // run over and over again
{
  getFingerprintIDez();
  delay(50);            //don't ned to run this at full speed.
}

uint8_t getFingerprintID() {
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("No finger detected");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK success!

  p = finger.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }
 
  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
    Serial.println("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    Serial.println("Did not find a match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }  
 
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.image2Tz();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  return -1;
 
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  return finger.fingerID;
 
 }






g. Video Hasilnya














No comments:

Post a Comment