Translate

Membuat Alat Buka Tutup Pagar / Pintu dan Door Lock Menggunakan Fingerprint dan ARDUINO - BASCOM AVR

Membuat Alat Buka Tutup Pagar dan Door LOck Menggunakan Fingerprint dan ARDUINO - BASCOM AVR


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat alat untuk simulasi buka-tutup pagar atau pintu menggunakan fingerprint dan ARDUINO sebagai decoder fingerprint. untuk pengolahan data pada alat ini menggunakan mikrokontroller ATMega16 yang mana menggunakan bahasa BASIC / BASCOM. alat ini dilengkapi dengan LCD dan sebuah tombol untuk keluar. kemudian driver motor dan driver solenoid doorlocknya. untuk lebih jelasnya berikut skema dan program dari alat ini. 




a. Arduino Uno




b. Minimum System 




c. Fingerprint




d. Solenoid Door Lock




e. Sensor SRF04




f. Driver Motor L293




g. Driver Solenoid Door Lock





h. 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;
 
 }




i. Program Bascom AVR

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

Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2


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 A As Integer

Dim X As Integer
X = 0

Config Timer0 = Timer , Prescale = 256
Config Timer1 = Pwm , Pwm = 8 , Prescale = 64 , Compare A Pwm = Clear Up

Config Portc.7 = Output
Config Pinc.6 = Input

Declare Sub Cek_jarak

Dim Data_jarak As Word
Dim Data_jarak_olah As Word
Dim Data_jarak_fix As Word

Triger1 Alias Portc.7
Pecho1 Alias Pinc.6

Ddrb.0 = 0
Ddrb.1 = 1
Ddrb.2 = 1
Ddrb.3 = 1

Set Portb.0


Cls
Cursor Off



Mulai:


Data_masuk = " "


On Urxc Getchar

Dim Inchar As String * 20

Enable Interrupts
Enable Urxc



Do

Upperline
Lcd "Letakkan Jari"

If Pinb.0 = 0 Then
Waitms 200
Goto Masukx
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)

      Lowerline
      Lcd "ID = " ; Cmd

     If Cmd = "0" Then

     Cls
     Upperline
     Lcd "Darso wahid"
     Lowerline
     Lcd "ID = " ; Cmd

     Wait 3
     Cls
     Goto Masukx


     Elseif Cmd = "1" Then

     Cls
     Upperline
     Lcd "turjanah"
     Lowerline
     Lcd "ID = " ; Cmd

     Wait 3
     Cls
     Goto Masukx

     Elseif Cmd = "2" Then

     Cls
     Upperline
     Lcd "marjuki oke"
     Lowerline
     Lcd "ID = " ; Cmd

     Wait 3
     Cls
     Goto Masukx

     Elseif Cmd = "3" Then

     Cls
     Upperline
     Lcd "tukiyem "
     Lowerline
     Lcd "ID = " ; Cmd

     Wait 3
     Cls
     Goto Masukx

     End If

   Else
   Return
   End If

Return




Sub Cek_jarak:
Reset Triger1
Waitus 10
Set Triger1
Waitus 20
Reset Triger1

Tcnt0 = 0
Bitwait Pecho1 , Set
Start Timer0

Do
If Pecho1 = 0 Then
Data_jarak = Tcnt0
Stop Timer0
Exit Do
End If

If Tifr.0 = 1 Then
Stop Timer0
Tifr.0 = 1
Data_jarak = &HFF
Exit Do
End If
Loop
Stop Timer0
Waitms 15
End Sub



Masukx:
Portb.3 = 1
Waitms 200
Do

Do
'mundur
Portb.1 = 0
Portb.2 = 1

Pwm1a = 150

Waitms 200

Incr X

Loop Until X > 5

'mundur
Portb.1 = 0
Portb.2 = 0

Pwm1a = 0
Wait 1

X = 0

Call Cek_jarak
  Data_jarak = Data_jarak
  Data_jarak_olah = Data_jarak * 100
  Data_jarak_fix = Data_jarak_olah / 256

If Data_jarak_fix > 10 Then
Do
'maju
Portb.1 = 1
Portb.2 = 0

Pwm1a = 150

Waitms 200

Incr X

Loop Until X > 5
X = 0
Portb.3 = 0

'mundur
Portb.1 = 0
Portb.2 = 0

Pwm1a = 0

Goto Mulai
End If


Loop






j. VIDEO HASILNYA

















No comments:

Post a Comment