Arduino Forum

Using Arduino => Storage => Topic started by: Rui_Teixeira on Mar 12, 2019, 10:54 pm

Title: Comparing data inside SD card with user Input
Post by: Rui_Teixeira on Mar 12, 2019, 10:54 pm
Hello everyone, I'm having a little problem with a project im developing.
I have a SD card connected to Arduino through a shield. I can read the data inside of it but can't compare it with a value that an user will lately insert. I've found some code examples on some websites but it didn't help that much.
Can anyone give me an example of a code to make it work???

Thank you.
Title: Re: Comparing data inside SD card with user Input
Post by: Paul_KD7HB on Mar 12, 2019, 11:36 pm
Can you give examples of the data you are trying to compare?

Paul
Title: Re: Comparing data inside SD card with user Input
Post by: Rui_Teixeira on Mar 13, 2019, 08:55 pm
I'm trying to compare a hexadecimal value.
If you need more info send me a message and I'll provide it to you.
Title: Re: Comparing data inside SD card with user Input
Post by: ieee488 on Mar 14, 2019, 12:32 am
I'm trying to compare a hexadecimal value.
If you need more info send me a message and I'll provide it to you.
No personal messaging should be required for something this simple.

You either know what you need or you don't.


.
Title: Re: Comparing data inside SD card with user Input
Post by: Lucario448 on Mar 14, 2019, 01:31 am
I'm trying to compare a hexadecimal value.
Written as text or it's merely a binary comparison?
Title: Re: Comparing data inside SD card with user Input
Post by: Rui_Teixeira on Mar 14, 2019, 10:32 am
Written as text or it's merely a binary comparison?
It is written in a .txt file.
Title: Re: Comparing data inside SD card with user Input
Post by: sterretje on Mar 14, 2019, 10:43 am
As the file extension is txt, I guess that the data in there is ascii.
User entries are usually text as well.

If you want to compare text, you can use strcmp (https://www.tutorialspoint.com/c_standard_library/c_function_strcmp.htm).

If one of them is not text, you can convert the text to a number using strtoul (https://www.tutorialspoint.com/c_standard_library/c_function_strtoul.htm)