用户工具

站点工具


技术细节:arduino库:arduino库文件介绍

Arduino库文件的使用

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.

Arduino标准库及其函数

Arduino标准库为IDE开发环境安装好后,自带的库文件。对应的函数为如下(详细解释参考官网函数介绍):

类别 简介 函数
Digital I/O数字接口控制digitalRead(),digitalWrite(),pinMode()
Analog I/O模拟接口控制analogRead(), analogReference(), analogWrite()
Time时间发生器delay(), delayMicroseconds(), micros(), millis()
Math数学计算abs(),constrain(), map(), max(), min(), pow(), sq(), sqrt()
Random Numbers随机数random(), randomSeed()
Trigonometry三角函数cos(), sin(), tan()
Bits and Bytes比特位或者字节操作bit(), bitClear(), bitRead(), bitSet(), bitWrite(), highByte(), lowByte()
Characters字符操作isAlpha(), isAlphaNumeric(), isAscii(), isControl(), isDigit(), isGraph(), isHexadecimalDigit(), isLowerCase(), isPrintable() , sPunct(), isSpace(), isUpperCase(), isWhitespace()
External Interrupts外部中断处理attachInterrupt(), detachInterrupt()
Advanced I/O高级接口控制noTone(), pulseIn(), pulseInLong(), shiftIn(), shiftOut(), tone()
Communication通讯控制Serial, Stream
USBUSB设备控制Keyboard, Mouse

Arduino标准库 (官网链接):

库名称 简介
EEPROMreading and writing to “permanent” storage
Ethernetfor connecting to the internet using the Arduino Ethernet Shield, Arduino Ethernet Shield 2 and Arduino Leonardo ETH
Firmatafor communicating with applications on the computer using a standard serial protocol.
GSMfor connecting to a GSM/GRPS network with the GSM shield.
LiquidCrystalfor controlling liquid crystal displays (LCDs)
SDfor reading and writing SD cards
Servofor controlling servo motors
SPIfor communicating with devices using the Serial Peripheral Interface (SPI) Bus
SoftwareSerialfor serial communication on any digital pins. Version 1.0 and later of Arduino incorporate Mikal Hart's NewSoftSerial library as SoftwareSerial.
Stepperfor controlling stepper motors
TFTfor drawing text , images, and shapes on the Arduino TFT screen
WiFifor connecting to the internet using the Arduino WiFi shield
WireTwo Wire Interface (TWI/I2C) for sending and receiving data over a net of devices or sensors.

安装Arduino扩展库

To install a new library into your Arduino IDE you can use the Library Manager (available from IDE version 1.6.2). Open the IDE and click to the “Sketch” menu and then Include Library > Manage Libraries.

Then the Library Manager will open and you will find a list of libraries that are already installed or ready for installation. In this example we will install the Bridge library. Scroll the list to find it, click on it, then select the version of the library you want to install. Sometimes only one version of the library is available. If the version selection menu does not appear, don't worry: it is normal.

Finally click on install and wait for the IDE to install the new library. Downloading may take time depending on your connection speed. Once it has finished, an Installed tag should appear next to the Bridge library. You can close the library manager.

安装.zip库文件

Libraries are often distributed as a ZIP file or folder. The name of the folder is the name of the library. 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. Starting with version 1.0.5, you can install 3rd party libraries in the IDE. Do not unzip the downloaded library, leave it as is.

In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library. At the top of the drop down list, select the option to “Add .ZIP Library''.

You will be prompted to select the library you would like to add. Navigate to the .zip file's location and open it.

Return to the Sketch > Include Library menu. menu. You should now see the library at the bottom of the drop-down menu. It is ready to be used in your sketch. The zip file will have been expanded in the libraries folder in your Arduino sketches directory.

NB: the Library will be available to use in sketches, but with older IDE versions examples for the library will not be exposed in the File > Examples until after the IDE has restarted.

安装自定义库

Arduino标准库

Arduino拓展库

参考资料

技术细节/arduino库/arduino库文件介绍.txt · 最后更改: 2021/04/22 14:28 由 imodu