i made a fingerprint activated nerf gun but when i scan my finger,it does not make the servo move.
PLEASE HELP!!!!!!
link: Fingerprint ID Nerf Gun - Hackster.io
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
Hi finn,
Can you post your code? Use code tags.
Can you post a link to the fingerprint scanner you purchased?
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:
thanks so much!
from finn
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.
yes,i have made the srvo move but in a different project.and yes the scanner does work.
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?