1 103 104 105 106 107 1,913 Replies Latest reply on Aug 6, 2014 3:11 PM by tonnie_wittenaar Go to original post Branched to a new discussion.
      • 1,560. Re: Have a question about Arduino? Ask me!
        hdormitzer

        I was wondering if someone could look over this code?

         

        I want it to control a solenoid with an Arduino. If the correct pass key is entered of a valid finger is used, I want it to print on a LCD access granted, and unlock the door. If not, I want the LCD to say "Access Denied" and stay locked.  When their is nothing, I want it to say "Henry's Workroom", with the time displayed below. All the hardware, I'm pretty confident on, I'm using a Arduino Mega so don't worry about the abundance of pins being used.




        #include <Wire.h>
        #include "RTClib.h"
        #include <LiquidCrystal.h>
        #include <Password.h>
        #include <Keypad.h>
        #include <Adafruit_Fingerprint.h>
        #if ARDUINO >= 100
         #include <SoftwareSerial.h>
        #else
         #include <NewSoftSerial.h>
        #endif
        
        
        RTC_DS1307 RTC;
        
        
        LiquidCrystal lcd(15, 14, 13, 12, 11, 10);
        
        
        int getFingerprintIDez();
        const int lockPin = 18;
        const int lcdRed = 15;
        const int lcdGreen = 16;
        const int lcdBlue = 17;
        
        
        // pin #1 is IN from sensor (GREEN wire)
        // pin #2 is OUT from arduino  (WHITE wire)
        #if ARDUINO >= 100
        SoftwareSerial mySerial(1, 2);
        #else
        NewSoftSerial mySerial(1, 2);
        #endif
        
        
        Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
        
        
        Password password = Password( "1234" );
        
        
        const byte ROWS = 4; // Four rows
        const byte COLS = 3; //  columns
        // Define the Keymap
        char keys[ROWS][COLS] = {
          {'1','2','3'},
          {'4','5','6'},
          {'7','8','9'},
          {'*','0','#'}
        };
        
        
        byte rowPins[ROWS] = { 9,8,7,6 };// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
        byte colPins[COLS] = { 5,4,3 };// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
        
        
        // Create the Keypad
        Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
        
        
        void setup()  
        {
          pinMode(lockPin, OUTPUT);
          pinMode(lcdRed, OUTPUT);
          pinMode(lcdGreen, OUTPUT);
          pinMode(lcdBlue, OUTPUT); 
          
          lcd.begin(16, 2);
          Serial.begin(9600);
          keypad.addEventListener(keypadEvent); //add an event listener for this keypad
          Serial.println("fingertest");
        
        
          // 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);
          }
          DateTime now = RTC.now();
          Serial.println("Waiting for valid finger...");
          lcd.noCursor();
          lcd.clear();
          lcd.print("HENRYS WORK ROOM");
          lcd.setCursor(5, 1);
          lcd.print(now.hour(), DEC);
          lcd.setCursor(7, 1);
          lcd.print(":");
          lcd.print(now.minute(), DEC);
          digitalWrite(lcdRed, LOW);
          digitalWrite(lcdGreen, LOW);
          digitalWrite(lcdBlue, HIGH);
          digitalWrite(lockPin, HIGH);
        }
        
        
        void loop() // run over and over again
        {
          getFingerprintIDez();
          keypad.getKey();
        }
        //take care of some special events
        void keypadEvent(KeypadEvent eKey){
          switch (keypad.getState()){
            case PRESSED:
          Serial.print("Pressed: ");
          Serial.println(eKey);
          switch (eKey){
           case '*': checkPassword(); break;
           case '#': password.reset(); break;
           default: password.append(eKey);
             }
          }
        } 
        
        
        void checkPassword(){
          if (password.evaluate()){
            Serial.println("Success");
            //Add code to run if it works
            DateTime now = RTC.now();
            lcd.clear();
            lcd.print("ACCESS GRANTED");
            digitalWrite(lcdRed, LOW);
            digitalWrite(lcdBlue, LOW);
            digitalWrite(lcdGreen, HIGH);
            digitalWrite(lockPin, LOW);
            delay(10000);
            lcd.clear();
            digitalWrite(lockPin, HIGH);
            lcd.print("HENRYS WORK ROOM");
            lcd.setCursor(5, 1);
            lcd.print(now.hour(), DEC);
            lcd.setCursor(7, 1);
            lcd.print(":");
            lcd.print(now.minute(), DEC);
            digitalWrite(lcdRed, LOW);
            digitalWrite(lcdGreen, LOW);
            digitalWrite(lcdBlue, HIGH);
            
          }else{
            DateTime now = RTC.now();
            Serial.println("Wrong");
            lcd.clear();
            lcd.print("ACCESS DENIED");
            digitalWrite(lcdBlue, LOW);
            digitalWrite(lcdGreen, LOW);
            digitalWrite(lcdRed, HIGH);
            digitalWrite(lockPin, HIGH);
            delay(10000);
            lcd.clear();
            lcd.print("HENRYS WORK ROOM");
            lcd.setCursor(5, 1);
            lcd.print(now.hour(), DEC);
            lcd.setCursor(7, 1);
            lcd.print(":");
            lcd.print(now.minute(), DEC);
            digitalWrite(lcdRed, LOW);
            digitalWrite(lcdGreen, LOW);
            digitalWrite(lcdBlue, HIGH);
            digitalWrite(lockPin, HIGH);
          }
        }
        
        
        uint8_t getFingerprintID() {
          uint8_t p = finger.getImage();
          switch (p) {
            case FINGERPRINT_OK:
              Serial.println("Image taken");
              break;
            case FINGERPRINT_NOFINGER:
              Serial.println("No finger detected");
              return p;
            case FINGERPRINT_PACKETRECIEVEERR:
              Serial.println("Communication error");
              return p;
            case FINGERPRINT_IMAGEFAIL:
              Serial.println("Imaging error");
              return p;
            default:
              Serial.println("Unknown error");
              return p;
          }
        
        
          // OK success!
        
        
          p = finger.image2Tz();
          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!
          p = finger.fingerFastSearch();
          if (p == FINGERPRINT_OK) {
            Serial.println("Found a print match!");
          } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
            Serial.println("Communication error");
            return p;
          } else if (p == FINGERPRINT_NOTFOUND) {
            Serial.println("Did not find a match");
            
            DateTime now = RTC.now();
            Serial.println("Wrong");
            lcd.clear();
            lcd.print("ACCESS DENIED");
            digitalWrite(lcdBlue, LOW);
            digitalWrite(lcdGreen, LOW);
            digitalWrite(lcdRed, HIGH);
            digitalWrite(lockPin, HIGH);
            delay(10000);
            lcd.clear();
            lcd.print("HENRYS WORK ROOM");
            lcd.setCursor(5, 1);
            lcd.print(now.hour(), DEC);
            lcd.setCursor(7, 1);
            lcd.print(":");
            lcd.print(now.minute(), DEC);
            digitalWrite(lcdRed, LOW);
            digitalWrite(lcdGreen, LOW);
            digitalWrite(lcdBlue, HIGH);
            digitalWrite(lockPin, HIGH);
            return p;
          } else {
            Serial.println("Unknown error");
            
            DateTime now = RTC.now();
            Serial.println("Wrong");
            lcd.clear();
            lcd.print("Unknown error");
            digitalWrite(lcdBlue, LOW);
            digitalWrite(lcdGreen, LOW);
            digitalWrite(lcdRed, HIGH);
            digitalWrite(lockPin, HIGH);
            delay(10000);
            lcd.clear();
            lcd.print("HENRYS WORK ROOM");
            lcd.setCursor(5, 1);
            lcd.print(now.hour(), DEC);
            lcd.setCursor(7, 1);
            lcd.print(":");
            lcd.print(now.minute(), DEC);
            digitalWrite(lcdRed, LOW);
            digitalWrite(lcdGreen, LOW);
            digitalWrite(lcdBlue, HIGH);
            digitalWrite(lockPin, HIGH);
            return p;
          }   
          
          // found a match!
          Serial.print("Found ID #"); Serial.print(finger.fingerID); 
          Serial.print(" with confidence of "); Serial.println(finger.confidence);
        }
        
        
        // 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!
            DateTime now = RTC.now();
            
            lcd.clear();
            lcd.print("ACCESS GRANTED");
            digitalWrite(lcdRed, LOW);
            digitalWrite(lcdBlue, LOW);
            digitalWrite(lcdGreen, HIGH);
            digitalWrite(lockPin, LOW);
            delay(10000);
            lcd.clear();
            digitalWrite(lockPin, LOW);
            lcd.print("HENRYS WORK ROOM");
            lcd.setCursor(5, 1);
            lcd.print(now.hour(), DEC);
            lcd.setCursor(7, 1);
            lcd.print(":");
            lcd.print(now.minute(), DEC);
            digitalWrite(lcdRed, LOW);
            digitalWrite(lcdGreen, LOW);
            digitalWrite(lcdBlue, HIGH);
            digitalWrite(lockPin, HIGH);
            
          Serial.print("Found ID #"); Serial.print(finger.fingerID); 
          Serial.print(" with confidence of "); Serial.println(finger.confidence);
          return finger.fingerID; 
        }
        
        • 1,561. Re: Have a question about Arduino? Ask me!
          sketchy

          Thank you for helping all of us!

           

          I am fairly new to circuits.  I am working with the RFM69. http://www.hoperf.com/upload/rf/RFM69HW-V1.3.pdf

           

          The pin out has 2 GND and 1 Connect To GND

           

          • why are there two GNDs?
          • how is connect to GND used?

          I was wiring such that connect to GND went into Arduino's GND.  But should I be using one of the GNDs?

          • 1,562. Re: Have a question about Arduino? Ask me!
            imyonjun

            Hi, i would like to ask you how to play a mp3 file with Arduino, using just an arduino board, no mp3shield etc needed

             

             

             

            the outline of my project is Arduino board---->relay--->mp3    means if there is a output high signal, it will trigger the relay to close the circuit and the mp3 will play

            • 1,563. Re: Have a question about Arduino? Ask me!
              peterwf

              Connect all terminals marked GND together and to the Arduino GND.

              • 1,564. Re: Have a question about Arduino? Ask me!
                donb

                I have RPi b model and  I have had in the recent past output on the HDMI and Video output ports but now on boot(HDMI port) I get the splash color screen then a popup that shows the boot choice of the operating system that it will boot to then the seconds count down to zero and screen goes blank and I do not see all the files being loaded or anything else. The video never comes back.  Also I get nothing if I go to Video port not even splash color screen.

                What has happened?

                • 1,565. Re: Have a question about Arduino? Ask me!
                  jw0752

                  Hi;

                  I am working on an Arduino C application that uses millis() to calculate time durations.  Since millis() is an unsigned long I have used unsigned long variables to do my time duration calculations as well. My concern is with the rollover of millis() approximately 50 days after a reset of the arduino. There is a possibility that my coding will try to calculate the duration of an event by subtracting the value of millis() before the rollover from the value of millis() after the rollover. Since unsigned long can't be negative what result will be stored in my duration variable. Will it be the absolute value of the difference between the two millis() readings or will it be gibberish? Any insight you can give me for dealing with this will be appreciated.

                  Thanks John Wiltrout

                  • 1,566. Re: Have a question about Arduino? Ask me!
                    mcb1

                    John

                    I was wisely told by someone to always subtract, so that any rollover will not cause that.

                    ie if (Millis() - storedMillis() > target) then do whatever.

                     

                     

                    Mark

                    • 1,567. Re: Have a question about Arduino? Ask me!
                      sketchy

                      I assume you were answering my question - why the RFM69 had 2 GND pins and what does the Connect to GND pin do.

                      Thank you for answering regarding the wiring.

                       

                      But...

                       

                      Why does the RFM69 have 2 GND pins when it only needs 1?

                       

                      What does Connect to GND do?  When would I use it?

                       

                      thank you.

                      • 1,568. Re: Have a question about Arduino? Ask me!
                        dmaruska

                        Hi Margaret Johnson,  Usually in a RF module you will find multiple grounds. RF can be very temperamental,  Sometimes the Digital GND and Power GND and RF GND are isolated from each other.  It could be due to a RF noise, it could be that they had an extra pin and decided to use it for GND and not leave it floating. Only the RF Engineer and PWB layout Designer will have that specific answer.  You could experiment and use only one and see if it operates correctly. From a user stand point, tie both to the GND on the Arduino.  Working in the Test Engineering field for over 20 years and working with RF for 30 years now.  More GNDS in RF the better…..


                        Regards,


                        Dave M.

                        • 1,569. Re: Have a question about Arduino? Ask me!
                          sketchy

                          Thank you Dave.  The reason for two GNDs makes a lot more sense put into context.  I was thinking maybe because there was an extra pin...but from what I know about the precision of engineers - this didn't strike me as the right answer :-).

                           

                          Do you know when I would use Connect to GND?

                          • 1,570. Re: Have a question about Arduino? Ask me!
                            dmaruska

                            Margaret,  When you look at and Antenna you will see there is two connections.  A GND and the RF Line or RF Power Connection. Most antenna stubs are SMA or BNC (there are LOT more RF connectors on the market to list here) connectors and they tie the shield of the Coax or connector outside to GND and the other would be used for Power GND.  You will have noticed that the RF line is isolated between the two GND lines. My assumption is for that reason, RF isolation, even PWR GND is connected to both points.  Remember the RF line is 50 ohms or as close to it. Designing a RF PWB takes the trace thickness, width, and board material and GND plane to achieve this. So based on all of these items, should answer your question.  All RF transmissions are referenced to a GND, be it earth, or any other in the circuit.

                             

                            Regards,

                             

                            Dave M.

                            • 1,571. Re: Have a question about Arduino? Ask me!
                              sketchy

                              Hi Dave,

                              Very helpful.  thank you!

                              • 1,572. Re: Have a question about Arduino? Ask me!
                                jw0752

                                Hi Mark,

                                It is good to hear from you again and thanks for your reply. It seems I haven't got the question asking procedure down yet as I seem to have butted into someone elses discussion. I believe I have followed your rule and do subtract the beginning millis() from the later sampled millis(). My concern however is at somepoint millis() will exceed the capacity of its register and will rollover to zero. If my first reading of millis is 4,294,967,000 and my later reading of millis() is 1,000 due to the rollover then my formula becomes Elapsed Time = 1,000 - 4,294,967,000. Since Elapsed Time is an unsigned long it can not contain a negative number.  What I need to know is what will be put into the Elapsed Time variable so I can properly code a fix. Will it be the absolute value of 1,000 - 4,294,967,000 or will it just be random gibberish?

                                Sorry to take advantage of your experience but while I have you I have another quick question. Is there a soft RESET available in arduino C?

                                I hope all is well with you. I assume you are beginning your summer down there. We have started winter with a bang. Already we have had several weeks of temperatures that have gotten as low as -20 C. Next month Millie and I are going to go somewhere warm for the rest of the winter.

                                Take care and thanks again for coming to my rescue.

                                Your friend John

                                • 1,573. Re: Have a question about Arduino? Ask me!
                                  mcb1

                                  John

                                  I'm at work sneaking a check of my emails ... hence the short answer.

                                  If you search the Arduino forum, someone kindly explained it to me.

                                  You might be able to find it by searching for mcb1, or else use Millis() and rollover.

                                   

                                  Flick me an email, rather than the forum.

                                  I will answer you later.

                                   

                                   

                                  Cheers

                                  mark

                                  • 1,574. Re: Have a question about Arduino? Ask me!
                                    nishy555

                                    Hi

                                    I am trying to make a LCD display project. Can you please help me in that

                                    Problem statement!!!

                                    "I want play IMAGES/TEXT/VIDEOS on a 84*48 GLCD

                                    I need following buttons

                                    1. Select
                                    2. Up
                                    3. Down
                                    4. Left
                                    5. Right
                                    6. Play/pause
                                    7. Contrast high
                                    8. contrast low
                                    9. Volume up
                                    10. Volume down
                                    11. Back

                                    My questions--

                                    1. Which kind of board should i need to use?
                                    2. I need to use 11 buttons/switches, So which kind of board/Micro controller allows me to use 11 switches?

                                    As i am a Mechanical Engineer i don't know much about electronics... So please help me.....