View previous topic :: View next topic |
Author |
Message |
ds
Joined: 01 Nov 2009 Posts: 15
|
Store Strings in Array for Comparison |
Posted: Mon Mar 29, 2010 11:27 pm |
|
|
Hi all,
I am working on an RFID reader module using a PIC16F688. I have the chip reading the serial data correctly and it can correctly identify a key. The only problem is that currently I have only one key stored. This is how I stored it:
Code: |
char password[11];
strcpy(password,"112254DFF5");
password[10]='\0';
|
and this is how I compared (which works):
Code: |
answer=strcmp(input,password);
|
How would I go about creating an array of passwords that I can compare with the "input" string. I want to be able to store a number of passwords, and I want the chip to cycle through each possibility before granting/denying access. I think I could come up with some sort of inefficient way to do this, however I was thinking maybe someone knew an easy way to do it!
Thanks!
DS. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
ds
Joined: 01 Nov 2009 Posts: 15
|
|
Posted: Tue Mar 30, 2010 11:32 am |
|
|
Thanks for the quick reply! This helps. I will take a look at it and try something out!
Thanks again!
DS. |
|
|
ds
Joined: 01 Nov 2009 Posts: 15
|
|
Posted: Wed Mar 31, 2010 2:38 pm |
|
|
This works great! However, how do I make it so that I can add keys without reprogramming to chip? How can I expand the array within the program? Or is this something better suited with another method?
Thanks!
DS |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 31, 2010 2:59 pm |
|
|
Put the new keys into Data EEprom (internal eeprom) inside the PIC.
Then when a password is entered by the user, read a key from data
eeprom into a RAM array. Compare it to the password. If it doesn't
match, then read the next key from data eeprom and compare it, and
so on.
You will need some way to know the number of keys that are stored
in data eeprom. You could allocate one byte in data eeprom to hold
the number of keys. Update that value whenever you add a new key.
I don't know if you intend to add new keys through a user interface,
(serial port ?) or if you intend to program data eeprom with an ICD. |
|
|
|