|
楼主 |
发表于 2020-2-18 18:53:06
|
显示全部楼层
- /*
- 【Arduino】168种传感器模块系列实验(资料+代码+图形+仿真)
- 实验一百五十:AS608光学指纹识别模块 智能锁/考勤门禁开发/指纹采集模块
- 实验之一:Adafruit指纹传感器,更改密码示例
- 安装库: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);
- // Using sensor without password
- Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
- // Using sensor with password
- //Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial, 1337);
- void setup()
- {
- while (!Serial); // For Yun/Leo/Micro/Zero/...
- Serial.begin(9600);
- Serial.println("Adafruit fingerprint sensor, change password example");
- // set the data rate for the sensor serial port
- finger.begin(19200);
- if (finger.verifyPassword()) {
- Serial.println("Found fingerprint sensor!");
- } else {
- Serial.println("Did not find fingerprint sensor :(");
- while (1);
- }
- Serial.print("Set password... ");
- uint8_t p = finger.setPassword(1337);
- if (p == FINGERPRINT_OK) {
- Serial.println("OK"); // Password is set
- } else {
- Serial.println("ERROR"); // Failed to set password
- }
- }
- void loop()
- {
- }
复制代码 |
|