-
-
Save WolfwithSword/755ac545b9c628aaaae39b6bf37d90e5 to your computer and use it in GitHub Desktop.
Arduino Uno fingerprint sensor testing program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "SoftwareSerial.h"; | |
const int Rx = 2; | |
const int Tx = 3; | |
SoftwareSerial mySerial(Rx, Tx); | |
const byte txBuf[] = {0xF5, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xF5}; | |
byte reply[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | |
void setup() { | |
pinMode(Rx, INPUT); | |
pinMode(Tx, OUTPUT); | |
Serial.begin(9600); | |
while (!Serial) { | |
; | |
} | |
Serial.println("Starting"); | |
mySerial.begin(19200); | |
while(!mySerial) { | |
; | |
} | |
} | |
void loop() { | |
while(mySerial.available()>0)mySerial.read(); | |
Serial.println(); | |
delay(1000); | |
while(mySerial.available()>0)mySerial.read(); | |
mySerial.write(txBuf, 8); | |
for (int i=0; i<8; i++) { | |
reply[i] = 0x00; | |
Serial.print(txBuf[i], HEX); | |
Serial.print(" "); | |
} | |
Serial.println("\nGetting data"); | |
delay(1000); | |
while(mySerial.available()<8){}; | |
int i=0; | |
byte x; | |
while(mySerial.available()>0){ | |
x = mySerial.read(); | |
reply[i] = x; | |
Serial.print(x, HEX); | |
Serial.print(' '); | |
i++; | |
} | |
Serial.println(); | |
if(reply[0]==0xF5 && reply[4]== 0x03 && reply[7]==0xF5){ | |
while(mySerial.available()>0)mySerial.read(); | |
Serial.println("SUCCESS"); | |
} | |
else{ | |
while(mySerial.available()>0)mySerial.read(); | |
Serial.println("FAIL"); | |
} | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment