From 7370be43612d8277b3c8b1bb4196452d19db7273 Mon Sep 17 00:00:00 2001 From: Siddharth Batra Date: Mon, 1 Oct 2018 01:25:38 +0530 Subject: [PATCH 1/5] Create VotingUsingFingerprintSensor --- VotingUsingFingerprinSensor.ino | 340 ++++++++++++++++++++++++++++++++ 1 file changed, 340 insertions(+) create mode 100644 VotingUsingFingerprinSensor.ino diff --git a/VotingUsingFingerprinSensor.ino b/VotingUsingFingerprinSensor.ino new file mode 100644 index 0000000..a2d1b9d --- /dev/null +++ b/VotingUsingFingerprinSensor.ino @@ -0,0 +1,340 @@ +#include +#include +SoftwareSerial mySerial(10, 11); +Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); +uint16_t id; +#include + +const byte ROWS = 4; //four rows +const byte COLS = 3; //three columns +char keys[ROWS][COLS] = { +{'1','2','3'}, +{'4','5','6'}, +{'7','8','9'}, +{'*','0','#'} +}; +byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the kpd +byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the kpd +Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); + +unsigned long loopCount; +unsigned long startTime; +String msg; +int l=0; +char a[3]; +int store[10]; +int spos=-1; +char cast_to=NO_KEY; + +void setup() { + // put your setup code here, to run once: + Serial.begin(9600); + loopCount = 0; + startTime = millis(); + msg = ""; + while (!Serial); // For Yun/Leo/Micro/Zero/... + delay(100); + // 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); + } + } +} +int readnumber(){ + int num = 0,t=0; + char key=NO_KEY; + do{ + key = kpd.getKey();} + while(key==NO_KEY); + while(t<3) + { + switch (key) + { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + num = num * 10 + (key - '0'); + break; + + case '*': + num = 0; + break; + } + t++; + do{key = kpd.getKey();} + while(key==NO_KEY); + } + if(t==3){ + Serial.println(num); + } + return num; + } +uint16_t getFingerprintEnroll() { + + int p = -1; + Serial.print("Waiting for valid finger to enroll as #"); Serial.println(id); + while (p != FINGERPRINT_OK) { + p = finger.getImage(); + switch (p) { + case FINGERPRINT_OK: + Serial.println("Image taken"); + break; + case FINGERPRINT_NOFINGER: + //Serial.println("."); + break; + case FINGERPRINT_PACKETRECIEVEERR: + Serial.println("Communication error"); + break; + case FINGERPRINT_IMAGEFAIL: + Serial.println("Imaging error"); + break; + default: + Serial.println("Unknown error"); + break; + } + } + + // OK success! + + p = finger.image2Tz(1); + switch (p) { + case FINGERPRINT_OK: + Serial.println("Image converted"); + break; + case FINGERPRINT_IMAGEMESS: + Serial.println("Image too messy"); + return p; + case FINGERPRINT_PACKETRECIEVEERR: + Serial.println("Communication error"); + return p; + case FINGERPRINT_FEATUREFAIL: + Serial.println("Could not find fingerprint features"); + return p; + case FINGERPRINT_INVALIDIMAGE: + Serial.println("Could not find fingerprint features"); + return p; + default: + Serial.println("Unknown error"); + return p; + } + + Serial.println("Remove finger"); + delay(2000); + p = 0; + while (p != FINGERPRINT_NOFINGER) { + p = finger.getImage(); + } + Serial.print("ID "); Serial.println(id); + p = -1; + Serial.println("Place same finger again"); + while (p != FINGERPRINT_OK) { + p = finger.getImage(); + switch (p) { + case FINGERPRINT_OK: + Serial.println("Image taken"); + break; + case FINGERPRINT_NOFINGER: + //Serial.print("."); + break; + case FINGERPRINT_PACKETRECIEVEERR: + Serial.println("Communication error"); + break; + case FINGERPRINT_IMAGEFAIL: + Serial.println("Imaging error"); + break; + default: + Serial.println("Unknown error"); + break; + } + } + + // OK success! + + p = finger.image2Tz(2); + switch (p) { + case FINGERPRINT_OK: + Serial.println("Image converted"); + break; + case FINGERPRINT_IMAGEMESS: + Serial.println("Image too messy"); + return p; + case FINGERPRINT_PACKETRECIEVEERR: + Serial.println("Communication error"); + return p; + case FINGERPRINT_FEATUREFAIL: + Serial.println("Could not find fingerprint features"); + return p; + case FINGERPRINT_INVALIDIMAGE: + Serial.println("Could not find fingerprint features"); + return p; + default: + Serial.println("Unknown error"); + return p; + } + + // OK converted! + Serial.print("Creating model for #"); Serial.println(id); + + p = finger.createModel(); + if (p == FINGERPRINT_OK) { + Serial.println("Prints matched!"); + } else if (p == FINGERPRINT_PACKETRECIEVEERR) { + Serial.println("Communication error"); + return p; + } else if (p == FINGERPRINT_ENROLLMISMATCH) { + Serial.println("Fingerprints did not match"); + return p; + } else { + Serial.println("Unknown error"); + return p; + } + + Serial.print("ID "); Serial.println(id); + p = finger.storeModel(id); + if (p == FINGERPRINT_OK) { + Serial.println("Stored!"); + } else if (p == FINGERPRINT_PACKETRECIEVEERR) { + Serial.println("Communication error"); + return p; + } else if (p == FINGERPRINT_BADLOCATION) { + Serial.println("Could not store in that location"); + return p; + } else if (p == FINGERPRINT_FLASHERR) { + Serial.println("Error writing to flash"); + return p; + } else { + Serial.println("Unknown error"); + return p; + } +} + +int getFingerprintIDez() { + int temp=0; + a: + uint16_t p = finger.getImage(); + if (p != FINGERPRINT_OK) goto a; + + p = finger.image2Tz(); + if (p != FINGERPRINT_OK) return -1; + + p = finger.fingerFastSearch(); + if (p != FINGERPRINT_OK){Serial.println("No Match Found!"); return -1;} + + // found a match! + if(finger.fingerID){ + Serial.print("Found ID #"); Serial.print(finger.fingerID); + //Serial.print(" with confidence of "); Serial.println(finger.confidence); + temp=1;} + if(temp==1){ + return finger.fingerID; + } + else{ + goto a; + } +} + + uint8_t deleteFingerprint(uint8_t id) { + uint8_t p = -1; + + p = finger.deleteModel(id); + + if (p == FINGERPRINT_OK) { + Serial.println("Deleted!"); + } else if (p == FINGERPRINT_PACKETRECIEVEERR) { + Serial.println("Communication error"); + return p; + } else if (p == FINGERPRINT_BADLOCATION) { + Serial.println("Could not delete in that location"); + return p; + } else if (p == FINGERPRINT_FLASHERR) { + Serial.println("Error writing to flash"); + return p; + } else { + Serial.print("Unknown error: 0x"); Serial.println(p, HEX); + return p; + } +} + +void loop() { + // put your main code here, to run repeatedly: + char what=NO_KEY; + int check,vote=1; + Serial.println("* for New,# for checking,0 for deleting"); + do{ + what=kpd.getKey(); + } + while(what==NO_KEY); + switch(what){ + case '*': + Serial.println("Ready to enroll a fingerprint!"); + Serial.println("Please type in the ID #you want to save this finger as..."); + id = readnumber(); + if (id == 0) {// ID #0 not allowed, try again! + return; + } + Serial.print("Enrolling ID #"); + Serial.println(id); + while (!getFingerprintEnroll() ); + break; + case '#': + Serial.println("Place Finger on Sensor"); + check=getFingerprintIDez(); + delay(50); + for(int i=0;i<=spos;i++) + { + if(check==store[i]) + { + Serial.println("This person has already casted vote!"); + vote=-1; + } + } + if(vote==1) + { + Serial.println("Allowed to Vote"); + store[++spos]=check; + Serial.println("You are now going to cast your vote!"); + Serial.println("Press the Serial Number infront of the party name to vote for their candidate!") + Serial.println("For more assistance on how to vote, please contact officer on duty!") + Serial.println("Vote for Bhartiya Janta Party"); + Serial.println("Vote for Congress"); + Serial.println("Vote for Aam Aadmi Party"); + Serial.println("Vote for Samajvadi Party"); + Serial.println("Vote for None of The Above"); + here: + do{ + cast_to=kpd.getKey(); + } + while(cast_to==NO_KEY) + switch(cast_to) + { + case '1': Serial.println("You voted for Bhartiya Janta Party");break; + case '2': Serial.println("You voted for Congress");break; + case '3': Serial.println("You voted for Aam Aadmi Party");break; + case '4': Serial.println("You voted for Samajvadi Party");break; + case '5': Serial.println("You voted for None of The Above");break; + default : Serial.println("You opted wrong option. Press a valid option!Try Again!");goto here;break; + } + + } + vote=1; + break; + case '0': + Serial.println("Please type in the ID # (from 100 to 999) you want to delete..."); + uint8_t id = readnumber(); + if (id == 0) {// ID #0 not allowed, try again! + return; + break; + } + + Serial.print("Deleting ID #"); + Serial.println(id); + + deleteFingerprint(id); +} +} From 7ef81854f4d0c74b1f90c332a69f89fc62ad899e Mon Sep 17 00:00:00 2001 From: Siddharth Batra Date: Tue, 2 Oct 2018 14:47:46 +0530 Subject: [PATCH 2/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 22ed70a..bccc6bc 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,4 @@ Bluetooth NRF # Feel Free To Contribute +You want more codes? From 2f623cf90f5ff18a5bac70d18515c3233b535d54 Mon Sep 17 00:00:00 2001 From: Kaushal Bhansali <30552428+Bin4ryGh0st@users.noreply.github.com> Date: Wed, 2 Oct 2019 00:14:57 +0530 Subject: [PATCH 3/5] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bccc6bc..57b6d39 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,10 @@ Ultra Sonic IR LDR -Node MCU +NodeMCU Bluetooth NRF - +R-Pi # Feel Free To Contribute You want more codes? +feel free to subscribe our Youtube Channel : https://www.youtube.com/channel/UChse-ROABYYEngsyWNeKxcw From b2dc7a6963cd2ed8db8801713ef55e76e5b40684 Mon Sep 17 00:00:00 2001 From: Kaushal Bhansali <30552428+Bin4ryGh0st@users.noreply.github.com> Date: Wed, 2 Oct 2019 00:16:21 +0530 Subject: [PATCH 4/5] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 57b6d39..749ec81 100644 --- a/README.md +++ b/README.md @@ -7,5 +7,5 @@ Bluetooth NRF R-Pi # Feel Free To Contribute -You want more codes? -feel free to subscribe our Youtube Channel : https://www.youtube.com/channel/UChse-ROABYYEngsyWNeKxcw +## You want more codes? +##### feel free to subscribe our Youtube Channel : https://www.youtube.com/channel/UChse-ROABYYEngsyWNeKxcw From e354dcb03bbfa252cb5d2747600475b2e8007756 Mon Sep 17 00:00:00 2001 From: Darshan-salecha <56079203+Darshan-salecha@users.noreply.github.com> Date: Sat, 12 Oct 2019 00:27:35 +0530 Subject: [PATCH 5/5] Create ultrasonic.ino --- ultrasonic.ino | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 ultrasonic.ino diff --git a/ultrasonic.ino b/ultrasonic.ino new file mode 100644 index 0000000..e3ba969 --- /dev/null +++ b/ultrasonic.ino @@ -0,0 +1,42 @@ +/* +* Ultrasonic Sensor HC-SR04 and Arduino Tutorial +* +* by Dejan Nedelkovski, +* www.HowToMechatronics.com +* +*/ + +// defines pins numbers +const int trigPin = 9; +const int echoPin = 10; + +// defines variables +long duration; +int distance; + +void setup() { +pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output +pinMode(echoPin, INPUT); // Sets the echoPin as an Input +Serial.begin(9600); // Starts the serial communication +} + +void loop() { +// Clears the trigPin +digitalWrite(trigPin, LOW); +delayMicroseconds(2); + +// Sets the trigPin on HIGH state for 10 micro seconds +digitalWrite(trigPin, HIGH); +delayMicroseconds(10); +digitalWrite(trigPin, LOW); + +// Reads the echoPin, returns the sound wave travel time in microseconds +duration = pulseIn(echoPin, HIGH); + +// Calculating the distance +distance= duration*0.034/2; + +// Prints the distance on the Serial Monitor +Serial.print("Distance: "); +Serial.println(distance); +}