37款传感器与执行器的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止这37种的。鉴于本人手头积累了一些传感器和执行器模块,依照实践出真知(一定要动手做)的理念,以学习和交流为目的,这里准备逐一动手尝试系列实验,不管成功(程序走通)与否,都会记录下来—小小的进步或是搞不掂的问题,希望能够抛砖引玉。
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验一百四十一:AS608光学指纹识别模块 智能锁/考勤门禁开发/指纹采集模块
08.jpeg【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验一百四十一:AS608光学指纹识别模块 智能锁/考勤门禁开发/指纹采集模块
实验之五:输入序号,删除指定指纹模板
Arduino实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验一百四十一:AS608光学指纹识别模块 智能锁/考勤门禁开发/指纹采集模块
实验之五:输入序号,删除指定指纹模板
安装库:IDE—工具—管理库—搜索Adafruit-Fingerprint-Sensor-Library—安装
实验接线:
Vi +3.3V(请勿接3.3V以上电源,否则烧毁模块!)
TX 2
RX 3
GND GND
*/
#include <Adafruit_Fingerprint.h>
// On Leonardo/Micro or others with hardware serial, use those! #0 is green wire, #1 is white
// uncomment this line:
// #define mySerial Serial1
// 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 (WHITE wire)
// comment these two lines if using hardware serial
SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
void setup()
{
Serial.begin(9600);
while (!Serial); // For Yun/Leo/Micro/Zero/...
delay(100);
Serial.println("\n\nDelete Finger");
// 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);
}
}
uint8_t readnumber(void) {
uint8_t num = 0;
while (num == 0) {
while (! Serial.available());
num = Serial.parseInt();
}
return num;
}
void loop() // run over and over again
{
Serial.println("lease type in the ID # (from 1 to 127) you want to delete...");
uint8_t id = readnumber();
if (id == 0) {// ID #0 not allowed, try again!
return;
}
Serial.print("Deleting ID #");
Serial.println(id);
deleteFingerprint(id);
}
uint8_t deleteFingerprint(uint8_t id) {
uint8_t p = -1;
p = finger.deleteModel(id);
if (p == FINGERPRINT_OK) {
Serial.println("Deleted!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("Communication error");
return p;
} else if (p == FINGERPRINT_BADLOCATION) {
Serial.println("Could not delete in that location");
return p;
} else if (p == FINGERPRINT_FLASHERR) {
Serial.println("Error writing to flash");
return p;
} else {
Serial.print("Unknown error: 0x"); Serial.println(p, HEX);
return p;
}
}
Delete Finger
Found fingerprint sensor!
Please type in the ID # (from 1 to 127) you want to delete...
删除指纹
找到指纹传感器!
请输入要删除的ID(从1到127)……
删除ID#9
删除!
请输入要删除的ID(从1到127)。。。
删除ID#8
删除!
请输入要删除的ID(从1到127)。。。
删除ID#7
删除!
请输入要删除的ID(从1到127)。。。
删除ID#6
删除!
请输入要删除的ID(从1到127)。。。
删除ID#5
删除!
请输入要删除的ID(从1到127)。。。
删除ID#4
删除!
请输入要删除的ID(从1到127)。。。
删除ID#3
删除!
请输入要删除的ID(从1到127)。。。
实验之六:删除所有指纹模板
Arduino实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验一百四十一:AS608光学指纹识别模块 智能锁/考勤门禁开发/指纹采集模块
实验之六:删除所有指纹模板
安装库:IDE—工具—管理库—搜索Adafruit-Fingerprint-Sensor-Library—安装
实验接线:
Vi +3.3V(请勿接3.3V以上电源,否则烧毁模块!)
TX 2
RX 3
GND GND
*/
#include <Adafruit_Fingerprint.h>
// On Leonardo/Micro or others with hardware serial, use those! #0 is green wire, #1 is white
// uncomment this line:
// #define mySerial Serial1
// 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 (WHITE wire)
// comment these two lines if using hardware serial
SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
void setup()
{
Serial.begin(9600);
while (!Serial); // For Yun/Leo/Micro/Zero/...
delay(100);
Serial.println("\n\nDeleting all fingerprint templates!");
Serial.println("ress 'Y' key to continue");
while (1) {
if (Serial.available() && (Serial.read() == 'Y')) {
break;
}
}
// 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);
}
finger.emptyDatabase();
Serial.println("Now database is empty ");
}
void loop() {
}
正在删除所有指纹模板!
按“Y”键继续
Found fingerprint sensor!
Now database is empty
找到指纹传感器!
现在数据库为空:)
模块接口
采用 8 芯 1.25 mm 间距单排插座,模块内部内置了手指探测电路,用户可读取状态引脚TCH(WAK)判断有无手指按下。
引脚号 名称 类型 功能描述
1 Vi In 模块电源正输入端+3.3V(请勿接3.3V以上电源,否则烧毁模块!)
2 TX Out 串行数据输出,接MCU或TTL串口的RX。
3 RX In 串行数据输入,接MCU或TTL串口的TX。
4 GND - 信号地。内部与电源地连接。
5 TCH Out 感应信号输出,默认高电平有效
6 UA In 触摸感应电源输入端,3.3v供电
7 D+ - USB D+
8 D- - USB D-
(7脚,8脚为USB信号线,使用串口控制模块时可以悬空不用)
网友评论