Should i unzipped the .zip file, then added both .c and .h file into “include” directory?
The preferred way is to NOT download the Arduino library yourself. Instead go to PIO Home / Libraries (in Visual Studio Code) or to https://platformio.org/lib and search for the library. If it is found, add the name of the library to
platformio.ini (an example can be seen if you click on the Installation tab in the search result). PlatformIO will then take care of the download, unpacking etc.
As an example: search for ArduinoJson. It’s a registered library. So you can then add it to
lib_deps = ArduinoJson
If the library is not registered, you can go the other route, e.g. for library ABC:
- Download the library
- Unzip the library
- Put it into the
libdirectory within your project
The project structure should then look like:
include lib +-- abc +-- examples +-- include +-- keywords.txt +-- library.json +-- src src test
Or if it is a very minimalistic library:
include lib +-- abc +-- abc.h +-- abc.c src test
Should I create file “library.json” myself or it would be created by PlatformIO?
I tried the second way you proposed, the question is: should I assert in
lib_deps = hd44780-1.3.0
This seems to have gone wrong here. Either
lib_deps should be used or the library should be put into the
libs directory but not both.
In addition, your error messages look as if you have renamed
hd44780.c. Now it’s compiled by the C compiler instead of the C++ compiler, resulting in many error messages.
Delete all files in the
lib folder and instead put the following lines into
lib_deps = hd44780
Or if the version number is important:
lib_deps = email@example.com
If you click Libraries (either in PlatformIO’s QUICK ACCESS or in the left bar on PlatformIO Home), you’ll find a UI to look up libraries and what you need to add
platformio.ini (tab Installation). hd44780 is a fully supported and registered library.
search for “hd44780” is an excellent suggestion, I searched “LCD1602” before, only two libraries shown.
And, there is another question:
After I installed a library, if I want to adjust some arguments value, for example, the pin number in it, where should I go?
Pin configuration is often solved with an
init() method or with a constructor taking pin numbers as parameters. It really depends on the library.
The hd44780 library has a GitHub repository with documentation and examples. As far as I can tell, it not only supports different pins but also different I/O schemes (I2C, serial, parallel etc.).
your error messages look as if you have renamed
hd44780.c . Now it’s compiled by the C compiler instead of the C++ compiler, resulting in many error messages.