Go Down

Topic: fingerprint scanner nerf gun (Read 621 times) previous topic - next topic

godboi123

i made a fingerprint activated nerf gun but when i scan my finger,it does not make the servo move.

PLEASE HELP!!!!!!
link: https://www.hackster.io/314reactor/fingerprint-id-nerf-gun-2ac7c0

wiring:
scanner: rx and tx=pins 2,3 gnd to breadboard gnd and 5v to breadboard 5v
servo:5v and gnd=breadboard 5v and gnd.signal to pin 9.
arduino 5v and ground to bread board + and -

from finn



vinceherman

Hi finn,
Can you post your code?  Use code tags.
Can you post a link to the fingerprint scanner you purchased?

godboi123


code:

//imports
#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#include <Servo.h>

//serial setup
SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
int fingerprintID = -1;

//servo setup
Servo servo1;
int pos = 0;

void setup(void) {
  //starting the fingerprint sensor and assigning the servo to pin 9
  startFingerprintSensor();
  servo1.attach(9);
}

//main loop of program
void loop() {
  //intial check of whether a finger is placed or not - if not keep the servo off of the safety button
  uint8_t p = finger.getImage();
  if (p == FINGERPRINT_NOFINGER) {
    Serial.println("SAFETYON");
    servo1.write(126);
    delay(1000);
  }
  else
  {
      //if a fingerprint is detected - run an ID on it to ensure it is mine
      fingerprintID = getFingerprintID();
      delay(50);
      //if so swing the servo over to the safety button, allowing the gun to fire
      if(fingerprintID == 1)
      {
        Serial.println("SAFETYOFF");
        servo1.write(145);
        delay(1000);
      }
  }
  Serial.print(fingerprintID);

}

void startFingerprintSensor()
{
  Serial.begin(9600);
  finger.begin(57600);
 
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor");
  }
  Serial.println("Waiting for valid finger...");
}

int getFingerprintID() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.image2Tz();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  return -1;
 
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  return finger.fingerID;

}





link to scanner:
https://www.aliexpress.com/item/FPM10A-Fingerprint-Reader-Sensor-Module-Optical-Fingerprint-Module-Serial-Communication-Interface-Fingerprint-Module-For-Arduino/32970224681.html?src=google&albslr=236909324&src=google&albch=shopping&acnt=494-037-6276&isdl=y&slnk=&plac=&mtctp=&albbt=Google_7_shopping&aff_platform=google&aff_short_key=UneMJZVf&&albagn=888888&albcp=1582410664&albag=59754279756&trgt=539263010115&crea=en32970224681&netw=u&device=c&gclid=CjwKCAjw67XpBRBqEiwA5RCocRlG-WLbz7P7JNOOxNXbif4QtLM90OGiFrSoHjGpelF648ctMqFHlBoCvqgQAvD_BwE&gclsrc=aw.ds


thanks so much!

from finn

vinceherman

A few things.
First - code tags.
If you do not know what they are, go read the sticky post at the tops of this forum named 'How to use this forum - please read'
If you are still unsure how to use code tags after you read that, let us know.

Second - I would troubleshoot the various components separately. 

Have you ever successfully made the servo move?  Try installing the sweep tutorial and see if your servo moves back and forth.
This will confirm that you have the servo wired up correctly.

Have you successfully used the fingerprint scanner?  Adafruit usually includes example code with their libraries.

After you confirm that you can make each piece work on their own, then you can combine them to work in your overall plan.




godboi123

yes,i have made the srvo move but in a different project.and yes the scanner does work.

vinceherman

Cool.
I would still run the sweep to confirm it is working now.
If it does, load back up your sketch from above.
Do you get any of the messages printed to the serial monitor?

Go Up