Advertisement
Guest User

FPS w/ 2 servos

a guest
Feb 22nd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1.  
  2. #include <Servo.h>
  3. #include "FPS_GT511C3.h"
  4. #include "SoftwareSerial.h"
  5.  
  6. Servo servo1;
  7. Servo servo2;// create servo objects to control a servo
  8. FPS_GT511C3 fps(3, 4);
  9.  
  10.  
  11. int pos1;
  12. int pos2; // variables to store the servo position
  13. int vfr = 0;
  14.  
  15. void setup() {
  16. servo1.attach(5);
  17. servo2.attach(6);// attaches the servo on pin 9 to the servo object
  18. Serial.begin(9600); //set up Arduino's hardware serial UART
  19. delay(100);
  20. fps.Open(); //send serial command to initialize fps
  21. fps.SetLED(true); //turn on LED so fps can see fingerprint
  22.  
  23. }
  24.  
  25. void loop()
  26. {
  27.  
  28.  
  29.  
  30. // Identify fingerprint test
  31. if (fps.IsPressFinger())
  32. {
  33. fps.CaptureFinger(false);
  34. int id = fps.Identify1_N();
  35.  
  36.  
  37. if (x < 2)
  38. {
  39.  
  40. for (int i=0; i<90; i += 1) {
  41. pos1 = 180 - i; // servo1 from 90 to 45 degrees
  42. pos2 = 0 + (2*i); // servo2 from 0 to 90 degrees
  43.  
  44. servo2.write(pos1);
  45. servo1.write(pos2);
  46. delay(50);
  47. }
  48. ++x;
  49. }
  50. }
  51.  
  52. else
  53. {//if unable to recognize fingerprint
  54. Serial.println("Finger not found");
  55. }
  56. }
  57. else
  58. {
  59. Serial.println("Please press finger");
  60. }
  61. delay(100);
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement