cfulfordBables14iupucmet
Published

Project 3 TLI-31300

Bar graph with LEDs and potentiometer using an analog into convert to a digital 4 byte integer for PWM control.

IntermediateShowcase (no instructions)578
Project 3 TLI-31300

Things used in this project

Hardware components

Rotary potentiometer (generic)
Rotary potentiometer (generic)
Γ—1
LED (generic)
LED (generic)
Γ—9
Arduino UNO
Arduino UNO
Γ—9
Resistor 100k ohm
Resistor 100k ohm
Γ—1
FInger print scanner
Γ—1

Story

Read more

Code

TLI-31300

C/C++
Comments in code
/*
 Casey Fulford Biometrics TLI 31300
 Project 3 - Bar Graph with Potentiometer 
 For this I used a fingerprint scanner to turn on the light program
 Need to register fingerprints with the Adafruit Enroll program 
  
 */

#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

int fingerprintID = 0;   // Set this to 0 for a place holder 

int getFingerprintIDez();  // Function declaraton. This calls the get.finger object from the Adafruit library 
const int potPin = A0; // Analog input pin connected to the potentiometer
int potValue = 0; // Value that will be read from the potentiometer
const int ledCount = 9;
int ledPins[] = {2,3,4,5,6,7,8,9,10};
boolean mainUser;  // This is a true / false for showing the main user 


void setup()  
{
  for (int thisLed = 0; thisLed < ledCount; thisLed++) 
  {
    pinMode(ledPins[thisLed], OUTPUT); // Set the LED pins as output
  }
  Serial.begin(9600);
  while (!Serial);  // For Yun/Leo/Micro/Zero/...
  delay(100);
  Serial.println("\n\nAdafruit finger detect test");

  // set the data rate for the sensor serial port
  finger.begin(57600);
  
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1) { delay(1); }
  }

  finger.getTemplateCount();
  Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates");
  Serial.println("Waiting for valid finger...");
}


void loop() 
  
{
  fingerprintID = getFingerprintIDez();
  delay(50);         
   if (fingerprintID == 1)
   {
   
     mainUser = true; 
   }
   else if (fingerprintID != 1)
   {
     mainUser = false;
   }
  while (mainUser)
  {
   int sensorReading = analogRead(analogPin); // Analog input
   int ledLevel = map(sensorReading, 0, 1023, 0, ledCount);
      for (int thisLed = 0; thisLed < ledCount; thisLed++) 
      {
        if (thisLed < ledLevel) 
        { 
          digitalWrite(ledPins[thisLed], HIGH);
        }
        else 
         { // Turn off LEDs in sequence
            digitalWrite(ledPins[thisLed], LOW);
         }
}
  }

  if (mainUser = false)
  {
    digitalWrite(buzzerPin, HIGH); // Send potentiometer value to LED
    digitalWrite(errorPin, HIGH); // Send potentiometer value to LED
    delay(500);

  }
} // end of main 

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  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; 
}
 

Credits

Baby Boilers

Posted by cfulford

Comments

Please log in or sign up to comment.