Cách cài đặt các thư viện phần cứng Arduino Library: Difference between revisions

From MakerLab Wiki
Jump to navigation Jump to search
(Created page with " 400px|right|thumb| == Installing Additional Arduino Libraries == Once you are comfortable with the Arduino software and using the built-in...")
 
No edit summary
 
(10 intermediate revisions by one other user not shown)
Line 1: Line 1:
== Thư viện Arduino Library là gì? ==
Thư viện [https://www.arduino.cc/en/Reference/Libraries Arduino Library] là những bộ tập lệnh được cộng đồng người sử dụng phần mềm Arduino xây dựng chuyên biệt cho các phần cứng kết nối với Arduino giúp bạn có thể dễ dàng lập trình bằng cách gọi các hàm trong thư viện Library của phần cứng tương ứng, thư viện Arduino Library được coi là nhân tố quan trọng giúp phần mềm Arduino phổ biến như hiện nay với hàng ngàn bộ thư viện cho vô số phần cứng khác nhau giúp tiết kiệm thời gian xây dựng chương trình.


[[Image:Arduino_quickstart.jpg|400px|right|thumb|]]
{{ArduinoLibraryManager_install}}


== Cách cài đặt Thư viện Arduino Library ==
Để cài đặt Thư viện Arduino Library cho phần cứng tương ứng, đầu tiên bạn cần tìm kiếm và tải bộ thư viện về máy tính, bộ thư viện sẽ dưới dạng file .ZIP trên Github, các bạn cần tải về như sau:
[[File:Screenshot 2023-07-10 at 18.08.42.png|alt=LiquidCrystal_I2C Arduino Library|none|thumb|700x700px|[https://github.com/makerlabvn/LiquidCrystal_I2C LiquidCrystal_I2C Arduino Library]]]
Sau khi tải về các bạn mở phần mềm Arduino chọn ''Sketch > Include Library > Add .ZIP Library...'', sau đó chọn file thư viện .ZIP vừa tải về để tiến hành cài đặt:
[[File:Screenshot 2023-07-10 at 17.57.55.png|alt=Add Library to Arduino|none|thumb|700x700px|Add Library to Arduino]]
Sau khi cài đặt thành công các bạn vào ''File > Examples'' sẽ thấy các Example của bộ thư viện cần cài đặt:
[[File:Screenshot 2023-07-10 at 18.00.31.png|alt=Arduino Library Examples|none|thumb|700x700px|Arduino Library Examples]]


== Installing Additional Arduino Libraries ==
== Tham khảo thêm ==
Once you are comfortable with the Arduino software and using the built-in functions,
'''Có thể tìm hiểu thêm về Thư viện Arduino Library tại đây:''' https://www.arduino.cc/en/Guide/Libraries
you may want to extend the ability of your Arduino with additional libraries.
 
== What are Libraries ? ==
[https://www.arduino.cc/en/Reference/Libraries  Libraries ]are a collection of code that makes it easy for you to connect to a sensor,display, module, etc. For example, the built-in LiquidCrystal library makes it easy to talk to character LCD displays. There are hundreds of additional libraries available on the Internet for download. The built-in libraries and some of these additional libraries are listed in the reference. To use the additional libraries, you will need to install them.
 
== How to Install a Library ? ==
Here we will introduce the most simple way for you to add libraries <br>
After download well the Arduino IDE, you can right-click the icon of Arduino IDE.<br>
Find the option "Open file location" shown as below.
<br>[[Image:Libraries 1.png|600px|frameless]]<br>
<br>
Then, click to open the libraries folder, you can directly add the libraries inside the folder.
<br>[[Image:Libraries 3.png|600px|frameless]]<br>
It is very easy for you to add the libraries in this way!
 
 
'''Or you can refer to another method to add libraries.''' <br>
Inside the folder will be a .cpp file, a .h file and often a keywords.txt file, examples folder, and other files required by the library.<br>
Take Arduino1.0.5 as an example, you can install a library in Arduino IDE. And do not unzip the downloaded library, leave it as is.
 
*In the Arduino IDE, click Skietch->Import Library.  Select “Add Library...” at the top of the drop down list.  <br>[[Image:Add Library.png|600px|frameless]]<br>
 
 
*You will be prompted to select the library you would like to add. Find the .zip file's location and open it. Here I select a library named smallePaper.  <br>[[Image:smallePaper.png|500px|frameless]]<br>
 
 
*Return to the Sketch > Import Library menu. You should now see the library at the bottom of the drop-down menu. It is ready to be used in your sketch.  <br>[[Image:your sketch.png|600px|frameless]]<br>
 
 
*Now the zip file has been installed in your Arduino sketches directory. You can see the location of the library: File->Preferences->Sketchbook location, and can change the location. Generally, we will change it as ….Arduino – 1.0.5\libraries as shown below.  <br>[[Image:below.png|600px|frameless]]<br>
 
 
'''More reference please click the link here:''' <br>
https://www.arduino.cc/en/Guide/Libraries

Latest revision as of 05:24, 12 October 2023

Thư viện Arduino Library là gì?

Thư viện Arduino Library là những bộ tập lệnh được cộng đồng người sử dụng phần mềm Arduino xây dựng chuyên biệt cho các phần cứng kết nối với Arduino giúp bạn có thể dễ dàng lập trình bằng cách gọi các hàm trong thư viện Library của phần cứng tương ứng, thư viện Arduino Library được coi là nhân tố quan trọng giúp phần mềm Arduino phổ biến như hiện nay với hàng ngàn bộ thư viện cho vô số phần cứng khác nhau giúp tiết kiệm thời gian xây dựng chương trình.

Cách cài đặt và cập nhật thư viện qua Arduino Library Manager

Cài đặt

Arduino IDE từ Version 1.6.2 trở đi đã hỗ trợ Library Manager. Đây là công cụ liệt kê danh sách các thư viện được sử dụng riêng cho các nền tảng mà Arduino hỗ trợ (Web IDE, PC IDE, ...). Thông qua công cụ này các bạn sẽ có những tiện lợi như là: Tên thư viện, tác giả, cập nhật phiên bản mới của thư viện, tự động truy vấn và cài đặt những thư viện có liên quan khác,...

Sau khi mở Arduino IDE chúng ta click và Menu Sketch -> Include Library -> Manage Libraries...

HD_LibraryManager_1
HD_LibraryManager1

Chọn tên thư viện, tên tác giả, version của thư viện, sau đó click Install. (Có thể sẽ có nhiều thư viện trùng tên nên cần phải để ý tên của tác giả)

HD_LibraryManager_2
HD_LibraryManager2

Nếu thư viện bạn chọn cần thêm các thư viện hỗ trợ khác, IDE sẽ thông báo như hình.

HD_LibraryManager_3_dependencies_library
HD_LibraryManager_3_dependencies_library

Để hạn chế IDE biên dịch lỗi thường sẽ chọn Install all (đối với newbie)


Cập nhật

Việc cập nhật thư viện các bạn mở Library Manager > chọn type: Updatable > nhập tên thư viện cần cập nhật

  • Để cập nhật version cuối cùng các bạn chỉ cần click Update
  • Bạn cũng có thể chọn bất kỳ version nào bạn cảm thấy tương thích với dự án của bạn sau đó click Install.
HD_LibraryManager_4_Update
HD_LibraryManager_4_Update

Cách cài đặt Thư viện Arduino Library

Để cài đặt Thư viện Arduino Library cho phần cứng tương ứng, đầu tiên bạn cần tìm kiếm và tải bộ thư viện về máy tính, bộ thư viện sẽ dưới dạng file .ZIP trên Github, các bạn cần tải về như sau:

Sau khi tải về các bạn mở phần mềm Arduino chọn Sketch > Include Library > Add .ZIP Library..., sau đó chọn file thư viện .ZIP vừa tải về để tiến hành cài đặt:

Add Library to Arduino
Add Library to Arduino

Sau khi cài đặt thành công các bạn vào File > Examples sẽ thấy các Example của bộ thư viện cần cài đặt:

Arduino Library Examples
Arduino Library Examples

Tham khảo thêm

Có thể tìm hiểu thêm về Thư viện Arduino Library tại đây: https://www.arduino.cc/en/Guide/Libraries