Kapii_Ornegi
Dependencies: mbed Servo MFRC522 TextLCD keypad
Revision 1:ce3de3f1306d, committed 2019-12-15
- Comitter:
- freedaom
- Date:
- Sun Dec 15 07:46:06 2019 +0000
- Parent:
- 0:eb13172d8708
- Commit message:
- Kapi_Uygulamasi
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Dec 15 07:31:34 2019 +0000
+++ b/main.cpp Sun Dec 15 07:46:06 2019 +0000
@@ -2,12 +2,10 @@
#include "TextLCD.h"
#include "Keypad.h"
#include <string>
-#include "Servo.h"
+#include "MFRC522.h"
-#include "MFRC522.h"/**/
-
-#define SIFRE "**123A"
-#define uzunluk 6
+#define SIFRE "**123A" // sifreyi kendinize göre değistirebilirsiniz
+#define uzunluk 6 // girdiğiniz sifre ne kadar uzunsa buraya sayısını giriniz
string sifre= "";
uint8_t hata=4;
@@ -27,6 +25,34 @@
MFRC522 RfChip(PA_7, PA_6, PA_5, PB_6, PC_7);/**/
+
+void hataliGiris()
+{
+ lcd.cls();
+ lcd.printf("Hatali Giris..");
+ for(uint8_t a = 10; a > 1; a--) {
+ buzzer=1;
+ wait_ms(50);
+ buzzer=0;
+ wait_ms(10);
+ }
+ buzzer=0;
+ hata--;
+ printf("Hatali Giris..");
+ wait(3);
+ lcd.cls();
+ sifre = "";
+ if(hata == 1) {
+ hata = 4;
+ lcd.printf(" saniye \n bekleyiniz..");
+ for(uint8_t sure = 60; sure > 0; sure--) {
+ lcd.locate(0,0);
+ lcd.printf("%d ",sure);
+ wait(1);
+ }
+ }
+}
+
int main()
{
uint32_t key_num;
@@ -35,13 +61,12 @@
Onur:
lcd.cls();
- servo1.SetPosition(20);
lcd.printf("Sifre : ");
printf("Sifre : ");
while(true) {
- while ((key_num = key.read()) != 0) {
-
+ while ((key_num = key.read()) != 0) { // keypada her basıldığında
+
buzzer=1;
wait_ms(50);
buzzer=0;
@@ -49,45 +74,22 @@
lcd.printf("*");
printf("%c", *(key_table + key_num-1));
- sifre += *(key_table + key_num-1);
+ sifre += *(key_table + key_num-1); // keypad deki değerler sifre adlı değişkende toplanıyor
if(uzunluk == sifre.length()) {
- if(sifre == SIFRE) {
+
+ if(sifre == SIFRE) { // eger ki sifremiz dogruysa
lcd.cls();
lcd.printf("Giris Basarili..");
printf("Giris Basarili...");
- servo1.SetPosition(150);
wait(3);
lcd.cls();
sifre = "";
hata=4;
goto Onur;
- } else {
- lcd.cls();
- lcd.printf("Hatali Giris..");
- for(uint8_t a = 10; a > 1; a--) {
- buzzer=1;
- wait_ms(50);
- buzzer=0;
- wait_ms(10);
- }
- buzzer=0;
- hata--;
- printf("Hatali Giris..");
- servo1.SetPosition(20);
- wait(3);
- lcd.cls();
- sifre = "";
- if(hata == 1) {
- hata = 4;
- lcd.printf(" saniye \n bekleyiniz..");
- for(uint8_t sure = 60; sure > 0; sure--) {
- lcd.locate(0,0);
- lcd.printf("%d ",sure);
- wait(1);
- }
- }
+ } else { // eger sifre hataliysa
+ hataliGiris();
goto Onur;
}
}
@@ -103,53 +105,32 @@
if ( ! RfChip.PICC_ReadCardSerial()) {
wait_ms(100);
continue;
- }
-
+ }
+
+// kard ID si yazdırılıyor
printf("Kart ID: ");
for (uint8_t i = 0; i < RfChip.uid.size; i++) {
printf(" %X", RfChip.uid.uidByte[i]);
}
printf("\n");
+// kendinize göre dğeiştirmeniz gerekiyor
if(RfChip.uid.uidByte[0]==0x53 && RfChip.uid.uidByte[1]==0x25 && RfChip.uid.uidByte[2]==0xB6 && RfChip.uid.uidByte[3]== 0x0) {
lcd.cls();
lcd.printf("Giris Basarili..");
printf("Giris Basarili...\n");
- servo1.SetPosition(150);
wait(3);
lcd.cls();
sifre = "";
hata=4;
- goto Onur;
- }
-
- else {
- lcd.cls();
- lcd.printf("Hatali Giris..");
- for(uint8_t a = 10; a > 1; a--) {
- buzzer=1;
- wait_ms(50);
- buzzer=0;
- wait_ms(10);
- }
- buzzer=0;
- hata--;
- printf("Hatali Giris..\n");
- servo1.SetPosition(20);
- wait(3);
- lcd.cls();
- sifre = "";
- if(hata == 1) {
- hata = 4;
- lcd.printf(" saniye \n bekleyiniz..");
- for(uint8_t sure = 60; sure > 0; sure--) {
- lcd.locate(0,0);
- lcd.printf("%d ",sure);
- wait(1);
- }
- }
goto Onur;
}
- return 0;
- }
-}
\ No newline at end of file
+
+ else { // RFID da okunan kart yanlis ise
+ hataliGiris();
+ goto Onur;
+ }
+
+ } // while(true) {
+ return 0;
+} // int main()
\ No newline at end of file
Marvas