Go Down

Topic: I2C_Keypad problem (Read 856 times) previous topic - next topic

LesserMole

To find any library that has example sketches do this:
  • Tools > Examples > open any example from the library you want to find


I think you mean File > Examples


pert

Thanks for the correction LesserMole! That was in of my collection of text snippets I use to copy/paste into my forum replies so it's definitely important for me to fix it.

sterretje

I have executed a small program to monitor temperature using internal sensor of DS3231RTC and to display it using I2C 16x2 LCD. I may include the following two header files in any combinations of double quotes and angle brackets; the program always works.

LiquidCrystal_I2C.h
Wire.h

When I searched my PC, I found the these header files under the directories as indicated.
LiquidCrystal_I2C.h : Could not trace the directory!?
Wire.h : c:\Program Files\Arduino\hardware\arduino\avr\libraries\Wire\src\Wire.h
Did you search complete drives? That library might well be in the documents folder.

My question: Is it really important for a programmer to care about the use of double quotes or angle brackets while including the header files? Traditionally, we are accustomed in the use of angle brackets.
Yes. Imagine you have a project with library A which is conflicting with another library B and your project requires both (usually interrupt conflicts).

You can modify one of those libraries in their original location, but that will affect all your previous projects and all future projects that use the modified version of the library and might result in errors in previously working sketches.

So you make a local copy of the library in your sketch directory, modify it, include using double quotes and you're done; no side effect. As pointed out by pert, you will have to check all files of the modified library as they all need to use double quotes when including the library specific files from the sketch directory.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

GolamMostafa

#18
Feb 16, 2018, 11:41 am Last Edit: Feb 16, 2018, 11:47 am by GolamMostafa
@pert

Following the guidelines of your Post#14, I have been able to trace the locations of the library files as follows:

1. Library files that are automatically installed when the IDE (1.8.0) is installed are found here:
a. c:\Program Files\Arduino\libraries\Library folders for 19 devices ike: LiquidCrystal and etc.
b. c:\Program Files\Arduino\hardware\arduino\avr\libraries\Library folders for 5 devices ike: SPI, Wire and etc.

2. Library files that are automatically installed when we download them as zip files, and later on include them using the IDE (Add .ZIP Library...).
c:\Users\GM\Documents\Arduino\libraries\Library folders for custom devices like: LiquidCrystal_I2C and etc.

Now, we see that there are three libraries; when you say standard library (Post#14), which library folder (1a, 1b, or 2) are you referring?  

BTW: Enabling verbose does not provide the above information (1a, 1b, and 2).

Many many thanks along with karma point.

GolamMostafa

#19
Feb 16, 2018, 12:03 pm Last Edit: Feb 16, 2018, 12:05 pm by GolamMostafa
@sterretje  
Quote
So you make a local copy of the library in your sketch directory, modify it, include using double quotes and you're done; no side effect.
About 27 years ago, as an Electrical Engineer, I wanted to learn DOS-C Programming and collected a book on C Programming where I encountered the case of the header file (s) being included using both double quotes and angle brackets. The question of the the then time -- what difference do they make -- is definitely better answered in Post#17. Thanks with +.

Quote
Did you search complete drives? That library might well be in the documents folder.
Yes! They are under c:\Users\GM\Documents folder; these Library Files are those files which we download as .zip files and later on include them using IDE (Add .ZIP Library...).

sterretje

The example I gave applies to open source environments where you can freely modify the source code. In the older days, you included stdio.h and the likes using <>. But once you got further you also started splitting your project into multiple files.

In the Arduino environment you can do that with multiple tabs which will live in your sketch directory. One option is to have multiple ino files, the other one is to have multiple .h and .c/.cpp files. And to include those, you need to include using the double quotes, else the 'user' directory is not searched for these files.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

pert

Now, we see that there are three libraries; when you say standard library (Post#14), which library folder (1a, 1b, or 2) are you referring?  
Any of those locations. I listed them in #10:
Actually there is a whole list of directories that are searched for the file:
  • Sketchbook: {sketchbook folder}/libraries. The sketchbook folder location can be found (or changed) at File > Preferences > Sketchbook location:.
  • IDE: {Arduino IDE install folder}/libraries. This is for the libraries included with the Arduino IDE installation.
  • Core: Libraries bundled with hardware packages. This is dependent on the current selection in Tools > Board. Location will depend on if you're using a hardware core bundled with the IDE, installed via Boards Manager, or manually installed to {sketchbook folder}/hardware.
  • Toolchain: The compiler package also provides library files that can be included (e.g. avr/wdt.h).

So your 1a is the IDE's libraries folder. Your 1b is the hardware core's libraries folder (but note that c:\Program Files\Arduino\hardware\arduino\avr\cores and c:\Program Files\Arduino\hardware\arduino\avr\variants are also in the search path). Your 2 is the sketchbook libraries folder.

GolamMostafa

Indeed, very good learning session that I have ever enjoyed in this Forum on such a complicated (conceptually) issue. Thanks to all contributors.

Go Up