So I'm trying to do a fingerprint project and my teacher wants it to take attendance. Each student will have an ID and scan the fingerprint sensor to get their ID number added to the array. The teacher ID is 99 and will pull up the array to see which students show up. I use my thumb as ID 1 than the teacher scan their thumb, but the array keeps displaying 0's.
int attnd_lst[5] = {0, 0, 0, 0, 0};
int i;
int a = 0;
Serial.print("Found ID #"); Serial.print(finger.fingerID);
Serial.print(" with confidence of "); Serial.println(finger.confidence);
if (finger.fingerID != 99){
attnd_lst[a] = {finger.fingerID};
a = a + 1;
return attnd_lst;
}
else{
Serial.println("Hi");
for (i = 0; i < 5; i++){
Serial.println(attnd_lst[i]);
}
}/code]
If anyone can help me or need me to go in greater depth please ask.
I can't tell from this code fragment. Is this a part of another function or part of the loop() function? It would help greatly if you posted your entire sketch.
The following code looks suspicious since I don't know to whom you are returning attnd_list to. You are returning a pointer to attnd_list which is on the stack and will not be valid upon return.
You have the following defined as local variables in your getFingerprintIDez() function:
int attnd_lst[5] = {0, 0, 0, 0, 0};
int a = 0;
Make those global and your code will mostly work; however, you need to check the index to make sure you don't write past the end of the attnd_lst array or it will get really weird.