160;
#include <SoftwareSerial.h>
#define BT_RXD 8
#define BT_TXD 7
SoftwareSerial bluetooth(BT_RXD, BT_TXD);
int buzzerPin = 4;
bool isDetection = false;
void setup()
{
160; Serial.begin(9600);
160; bluetooth.begin(9600);
160; pinMode(buzzerPin, OUTPUT);
}
void loop()
{
160; byte data;
160; while (bluetooth.available() > 0)
160; {
160; 160; data = bluetooth.read();
160; 160; Serial.write(data);
160; 160; if (isDetection && data == 75)
160; 160; {
160; 160; 160; Buzzer();
160; 160; }
160; 160; isDetection = false;
160; 160; if (data == 79)
160; 160; {
160; 160; 160; isDetection = true;
160; 160; }
160; }
}
void Buzzer()
{
160; Serial.write("disconnected");
160; tone(buzzerPin, 131);
160; delay(5000);
160; noTone(buzzerPin);
160; delay(1000);
160; tone(buzzerPin, 262);
160; delay(5000);
160; noTone(buzzerPin);
160; delay(1000);
}
==========================================================
#include <Adafruit_Fingerprint.h>
#if (defined(__AVR__) || defined(ESP8266)) && !defined(__AVR_ATmega2560__)
// For UNO and others without hardware serial, we must use software serial...
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino 160;(WHITE wire)
// Set up the serial port to use softwareserial..
SoftwareSerial mySerial(2, 3);
#else
// On Leonardo/M0/etc, others with hardware serial, use hardware serial!
// #0 is green wire, #1 is white
#define mySerial Serial1
#endif
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
int Relay = 13;
void setup()
{
160; pinMode(Relay, OUTPUT);
160; //digitalWrite(Relay,HIGH);
160; Serial.begin(9600);
160; while (!Serial); 160;// For Yun/Leo/Micro/Zero/...
160; delay(100);
160; Serial.println("\n\nAdafruit finger detect test");
160; // set the data rate for the sensor serial port
160; finger.begin(57600);
160; delay(5);
160; if (finger.verifyPassword()) {
160; 160; Serial.println("Found fingerprint sensor!");
160; } else {
160; 160; Serial.println("Did not find fingerprint sensor :(");
160; 160; while (1) {
160; 160; 160; delay(1);
160; 160; }
160; }
160; Serial.println(F("Reading sensor parameters"));
160; finger.getParameters();
160; Serial.print(F("Status: 0x")); Serial.println(finger.status_reg, HEX);
160; Serial.print(F("Sys ID: 0x")); Serial.println(finger.system_id, HEX);
160; Serial.print(F("Capacity: ")); Serial.println(finger.capacity);
160; Serial.print(F("Security level: ")); Serial.println(finger.security_level);
160; Serial.print(F("Device address: ")); Serial.println(finger.device_addr, HEX);
160; Serial.print(F("Packet len: ")); Serial.println(finger.packet_len);
160; Serial.print(F("Baud rate: ")); Serial.println(finger.baud_rate);
160; finger.getTemplateCount();
160; if (finger.templateCount == 0) {
160; 160; Serial.print("Sensor doesn't contain any fingerprint data. Please run the 'enroll' example.");
160; }
160; else {
160; 160; Serial.println("Waiting for valid finger...");
160; 160; Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates");
160; }
160; 160;//digitalWrite(Relay,LOW);
}
void loop() 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; // run over and over again
{
160; //digitalWrite(Relay,LOW);
160; getFingerprintID();
160; delay(50); 160; 160; 160; 160; 160; 160;//don't ned to run this at full speed.
}
uint8_t getFingerprintID() {
160; uint8_t p = finger.getImage();
160; switch (p) {
160; 160; case FINGERPRINT_OK:
160; 160; 160; Serial.println("Image taken");
160; 160; 160; break;
160; 160; case FINGERPRINT_NOFINGER:
160; 160; 160; Serial.println("No finger detected");
160; 160; 160; return p;
160; 160; case FINGERPRINT_PACKETRECIEVEERR:
160; 160; 160; Serial.println("Communication error");
160; 160; 160; return p;
160; 160; case FINGERPRINT_IMAGEFAIL:
160; 160; 160; Serial.println("Imaging error");
160; 160; 160; return p;
160; 160; default:
160; 160; 160; Serial.println("Unknown error");
160; 160; 160; return p;
160; }
160; // OK success!
160; p = finger.image2Tz();
160; switch (p) {
160; 160; case FINGERPRINT_OK:
160; 160; 160; Serial.println("Image converted");
160; 160; 160; break;
160; 160; case FINGERPRINT_IMAGEMESS:
160; 160; 160; Serial.println("Image too messy");
160; 160; 160; return p;
160; 160; case FINGERPRINT_PACKETRECIEVEERR:
160; 160; 160; Serial.println("Communication error");
160; 160; 160; return p;
160; 160; case FINGERPRINT_FEATUREFAIL:
160; 160; 160; Serial.println("Could not find fingerprint features");
160; 160; 160; return p;
160; 160; case FINGERPRINT_INVALIDIMAGE:
160; 160; 160; Serial.println("Could not find fingerprint features");
160; 160; 160; return p;
160; 160; default:
160; 160; 160; Serial.println("Unknown error");
160; 160; 160; return p;
160; }
160; // OK converted!
160; p = finger.fingerSearch();
160; if (p == FINGERPRINT_OK) {
160; 160; Serial.println("Found a print match!");
160; 160; digitalWrite(Relay, HIGH);
160; } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
160; 160; Serial.println("Communication error");
160; 160; return p;
160; } else if (p == FINGERPRINT_NOTFOUND) {
160; 160; Serial.println("Did not find a match");
160; 160; digitalWrite(Relay, LOW);
160; 160; return p;
160; } else {
160; 160; Serial.println("Unknown error");
160; 160; return p;
160; }
160; // found a match!
160; Serial.print("Found ID #"); Serial.print(finger.fingerID);
160; Serial.print(" with confidence of "); Serial.println(finger.confidence);
160; return finger.fingerID;
}
// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
160; uint8_t p = finger.getImage();
160; if (p != FINGERPRINT_OK) 160;return -1;
160; p = finger.image2Tz();
160; if (p != FINGERPRINT_OK) 160;return -1;
160; p = finger.fingerFastSearch();
160; if (p != FINGERPRINT_OK) 160;return -1;
160; // found a match!
160; Serial.print("Found ID #"); Serial.print(finger.fingerID);
160; Serial.print(" with confidence of "); Serial.println(finger.confidence);
160; return finger.fingerID;
}
========================================================
#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#define BT_RXD 8
#define BT_TXD 7
SoftwareSerial bluetooth(BT_RXD, BT_TXD);
int buzzerPin = 4;
int Relay = 13;
bool isDetection = false;
#if (defined(__AVR__) || defined(ESP8266)) && !defined(__AVR_ATmega2560__)
// For UNO and others without hardware serial, we must use software serial...
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino 160;(WHITE wire)
// Set up the serial port to use softwareserial..
SoftwareSerial mySerial(2, 3);
#else
// On Leonardo/M0/etc, others with hardware serial, use hardware serial!
// #0 is green wire, #1 is white
#define mySerial Serial1
#endif
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
void setup()
{
160; pinMode(Relay, OUTPUT);
160; pinMode(buzzerPin, OUTPUT);
160; Serial.begin(57600);
160; bluetooth.begin(57600);
160; while (!Serial); 160;// For Yun/Leo/Micro/Zero/...
160; delay(100);
160; Serial.println("\n\nAdafruit finger detect test");
160; finger.begin(57600);
160; delay(5);
160; if (finger.verifyPassword()) {
160; 160; Serial.println("Found fingerprint sensor!");
160; } else {
160; 160; Serial.println("Did not find fingerprint sensor :(");
160; 160; while (1) {
160; 160; 160; delay(1);
160; 160; }
160; }
160; Serial.println(F("Reading sensor parameters"));
160; finger.getParameters();
160; Serial.print(F("Status: 0x")); Serial.println(finger.status_reg, HEX);
160; Serial.print(F("Sys ID: 0x")); Serial.println(finger.system_id, HEX);
160; Serial.print(F("Capacity: ")); Serial.println(finger.capacity);
160; Serial.print(F("Security level: ")); Serial.println(finger.security_level);
160; Serial.print(F("Device address: ")); Serial.println(finger.device_addr, HEX);
160; Serial.print(F("Packet len: ")); Serial.println(finger.packet_len);
160; Serial.print(F("Baud rate: ")); Serial.println(finger.baud_rate);
160; finger.getTemplateCount();
160; if (finger.templateCount == 0) {
160; 160; Serial.print("Sensor doesn't contain any fingerprint data. Please run the 'enroll' example.");
160; }
160; else {
160; 160; Serial.println("Waiting for valid finger...");
160; 160; Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates");
160; }
}
void loop() 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; // run over and over again
{
160; 160; byte data;
160; while (bluetooth.available() > 0)
160; {
160; 160; data = bluetooth.read();
160; 160; Serial.write(data);
160; 160; if (isDetection && data == 75)
160; 160; {
160; 160; 160; Buzzer();
160; 160; }
160; 160; isDetection = false;
160; 160; if (data == 79)
160; 160; {
160; 160; 160; isDetection = true;
160; 160; }
160; }
160; getFingerprintID();
160; delay(50); 160; 160; 160; 160; 160; 160;//don't ned to run this at full speed.
}
uint8_t getFingerprintID() {
160; uint8_t p = finger.getImage();
160; switch (p) {
160; 160; case FINGERPRINT_OK:
160; 160; 160; Serial.println("Image taken");
160; 160; 160; break;
160; 160; case FINGERPRINT_NOFINGER:
160; 160; 160; Serial.println("No finger detected");
160; 160; 160; return p;
160; 160; case FINGERPRINT_PACKETRECIEVEERR:
160; 160; 160; Serial.println("Communication error");
160; 160; 160; return p;
160; 160; case FINGERPRINT_IMAGEFAIL:
160; 160; 160; Serial.println("Imaging error");
160; 160; 160; return p;
160; 160; default:
160; 160; 160; Serial.println("Unknown error");
160; 160; 160; return p;
160; }
160; // OK success!
160; p = finger.image2Tz();
160; switch (p) {
160; 160; case FINGERPRINT_OK:
160; 160; 160; Serial.println("Image converted");
160; 160; 160; break;
160; 160; case FINGERPRINT_IMAGEMESS:
160; 160; 160; Serial.println("Image too messy");
160; 160; 160; return p;
160; 160; case FINGERPRINT_PACKETRECIEVEERR:
160; 160; 160; Serial.println("Communication error");
160; 160; 160; return p;
160; 160; case FINGERPRINT_FEATUREFAIL:
160; 160; 160; Serial.println("Could not find fingerprint features");
160; 160; 160; return p;
160; 160; case FINGERPRINT_INVALIDIMAGE:
160; 160; 160; Serial.println("Could not find fingerprint features");
160; 160; 160; return p;
160; 160; default:
160; 160; 160; Serial.println("Unknown error");
160; 160; 160; return p;
160; }
160; // OK converted!
160; p = finger.fingerSearch();
160; if (p == FINGERPRINT_OK) {
160; 160; Serial.println("Found a print match!");
160; 160; digitalWrite(Relay, HIGH);
160; } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
160; 160; Serial.println("Communication error");
160; 160; return p;
160; } else if (p == FINGERPRINT_NOTFOUND) {
160; 160; Serial.println("Did not find a match");
160; 160; digitalWrite(Relay, LOW);
160; 160; return p;
160; } else {
160; 160; Serial.println("Unknown error");
160; 160; return p;
160; }
160; Serial.print("Found ID #"); Serial.print(finger.fingerID);
160; Serial.print(" with confidence of "); Serial.println(finger.confidence);
160; return finger.fingerID;
}
// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
160; uint8_t p = finger.getImage();
160; if (p != FINGERPRINT_OK) 160;return -1;
160; p = finger.image2Tz();
160; if (p != FINGERPRINT_OK) 160;return -1;
160; p = finger.fingerFastSearch();
160; if (p != FINGERPRINT_OK) 160;return -1;
160; // found a match!
160; Serial.print("Found ID #"); Serial.print(finger.fingerID);
160; Serial.print(" with confidence of "); Serial.println(finger.confidence);
160; return finger.fingerID;
}
void Buzzer()
{
160; Serial.write("disconnected");
160; tone(buzzerPin, 131);
160; delay(5000);
160; noTone(buzzerPin);
160; delay(1000);
160; tone(buzzerPin, 262);
160; delay(5000);
160; noTone(buzzerPin);
160; delay(1000);
}
========================================
코드가 길Ǻ12; 1396;송합니다.
첫번1704; 코드lj16; 블루투스 연결 후 블루투스가 -130;Ǻ12;1648;면 ǥ12;1200;를 울리/140;고 만들었습니다.
.160;번1704; 코드lj16; 릴/112;1060;에 솔/112;노1060;드와 1648;문1064;식1109;치/196; 1104;금1109;치를 만들Ǻ12; 보고1088; Ȣ16;였습니다.
세번1704; 코드lj16; 위1032; .160; 기능1012; Ȣ16;나1032; 아.160;1060;노에 1665;Ǻ12;넣고 dz10;Ǻ12; 합쳐봤습니다.
다만 .160; 코드 합치1648; 않고 각1088; 썼1012;ǐ16; 문1228;가 없었lj16;데 세번1704; 코드에서 ǥ12;1200; ǥ12;ǥ16;1060; 1089;ᇼ1;1060; 안.121;니다.
블루투스 연결, 1648;문1060; 1068;치Ȣ16;면 1104;금 off 모.160; 1089;ᇼ1;Ȣ16;lj16;데 블루투스가 -130;Ǻ12;1656; ǐ12; ǥ12;1200;를 울리도/197; Ȣ16;lj16; 기능1060; 1089;ᇼ1;Ȣ16;1656; 않습니다.
.160; 코드를 합치면서 1228;가 실수한 ǥ12;ǥ16;1060; 1080;lj16;1648; 가르쳐1452;시면 1221;말 도움 많1060; .112; ,163; 같습니다.
{
byte data;
while (bluetooth.available() > 0)
{
data = bluetooth.read();
Serial.write(data);
if (isDetection && data == 75)
{
Buzzer();
}
isDetection = false;
if (data == 79)
{
isDetection = true;
}
}
getFingerprintID();
delay(50); //don't ned to run this at full speed.
}
BT°¡ available ÇÒ¶§¸¸ loop°¡ À¯ÁöµÇ°í unavailable Çϸé while()¿¡¼ ƨ°Ü ³ª°¡¸é¼
get FingerpirntID(); delay(50)¸¸ ½ÇÇàµÇ°í
BT°¡ ¿ì¿¬È÷ available ÇØÁöÁö ¾Ê´Â ÀÌ»ó ´Ù½Ã Àú ¾ÈÀÇ ·çÇÁ·Î µé¾î°¡Áö ¸øÇÏ°Ô µË´Ï´Ù.
¾ÆµÎÀ̳ëÀÇ °æ¿ì loop() ÇÔ¼ö¿¡¼ ¶Ç loop¸¦ µ¹¸®´Â°Ô ¿ÇÀº ÇÁ·Î±×·¡¹Ö ¹æÇâÀÌ ¾Æ´Ò°Ì´Ï´Ù.
loop() ÇÔ¼ö ÀÚü¸¦ »óÀ§ (º¸ÀÌÁö ¾Ê´Â) Äڵ忡¼ while()¿¡ ÀÇÇؼ µ¹¸®°í Àֱ⠶§¹®ÀÌÁÒ.
¾Æ¹«Æ° ±»ÀÌ ¼öÁ¤À» ÇØ¾ß ÇÑ´Ù¸é
if(bt.available() > 0)
{ // BT Á¤»ó
}
else
{
Buzzer(); // BT not available
Serial.println("BT failed.");
// bluetooth.reinit()..
}
½ÄÀ¸·Î ±¸ÇöÇÏ½Ã¸é µÉ °Í °°½À´Ï´Ù.
ÇØ´çÇÔ¼ö´Â BTÀÇ »ýÁ¸À» È®ÀÎÇÏ´Â°Ô ¾Æ´Ï¶ó ¼ÒÇÁÆ®¿þ¾î ½Ã¸®¾ó Æ÷Æ®¸¦ ÅëÇØ µ¥ÀÌÅÍ°¡ ÀÐÈ÷´Â°Ô ÀÖ³Ä? ¶ó´Â ±â´ÉÀ» °¡Áø ÇÔ¼ö °°½À´Ï´Ù.
BT ¿Í Åë½ÅÀ» ½ÃµµÇÏ°í timeout ÀÌÈÄ Á×¾ú´Ù°í ÆǴܵǸé else ºÎºÐÀ» ±¸µ¿Çϵµ·Ï º¯°æÇÒ ÇÊ¿ä°¡ ÀÖÀ» °Í °°½À´Ï´Ù.