当前位置:网站首页>【Arduino】重生之Arduino 学僧(3)----Arduino函数
【Arduino】重生之Arduino 学僧(3)----Arduino函数
2022-08-03 01:42:00 【垮起个老脸】
在学习Arduino中,会遇到很多的调整函数来实现相关功能,使用C语言或者JAVA语言来实现:
常用的函数已经列出,后面补充Arduino语音库文件
目录
时间函数
- unsigned long millis() 返回时间函数(单位ms),该函数是指,当程序运行就开始计时并返回记录的参数,该参数溢出大概需要50天时间。
- delay(ms) 延时函数(单位ms)。
- delayMicroseconds(us) 延时函数(单位us)。
数学函数
- min(x, y) 求最小值
- max(x, y) 求最大值
- abs(x) 计算绝对值
- constrain(x, a, b) 约束函数,下限a,上限b,x必须在ab之间才能返回。
- map(value, fromLow, fromHigh, toLow, toHigh) 约束函数,value必须在fromLow与toLow之间和fromHigh与toHigh之间。
- pow(base, exponent) 开方函数,base的exponent次方。
- sq(x) 平方
- sqrt(x) 开根号
三角函数
随机数函数
- randomSeed(seed) 随机数端口定义函数,seed表示读模拟口analogRead(pin)函数 。
- long random(max) 随机数函数,返回数据大于等于0,小于max。
- long random(min, max) 随机数函数,返回数据大于等于min,小于max。
外部中断函数
- attachInterrupt(interrupt, , mode) 外部中断只能用到数字IO口2和3,interrupt表示中断口初始0或1,表示一个功能函数,mode:LOW低电平中断,CHANGE有变化就中断,RISING上升沿中断,FALLING 下降沿中断。
- detachInterrupt(interrupt) 中断开关,interrupt=1 开,interrupt=0 关。
中断使能函数
- interrupts() 使能中断
- noInterrupts() 禁止中断
串口收发函数
- Serial.begin(speed) 串口定义波特率函数,speed表示波特率,如9600,19200等。
- int Serial.available() 判断缓冲器状态。
- int Serial.read() 读串口并返回收到参数。
- Serial.flush() 清空缓冲器。
- Serial.print(data) 串口输出数据。
- Serial.println(data) 串口输出数据并带回车符。
补充:Arduino语言库文件
官方库文件
- EEPROM - EEPROM读写程序库
- Ethernet - 以太网控制器程序库
- LiquidCrystal - LCD控制程序库
- Servo - 舵机控制程序库
- SoftwareSerial - 任何数字IO口模拟串口程序库
- Stepper - 步进电机控制程序库
- Wire - TWI/I2C总线程序库
- Matrix - LED矩阵控制程序库
- Sprite - LED矩阵图象处理控制程序库
非官方库文件
- DateTime - a library for keeping track of the current date and time in software.
- Debounce - for reading noisy digital inputs (e.g. from buttons)
- Firmata - for communicating with applications on the computer using a standard serial protocol.
- GLCD - graphics routines for LCD based on the KS0108 or equivalent chipset.
- LCD - control LCDs (using 8 data lines)
- LCD 4 Bit - control LCDs (using 4 data lines)
- LedControl - for controlling LED matrices or seven-segment displays with a MAX7221 or MAX7219.
- LedControl - an alternative to the Matrix library for driving multiple LEDs with Maxim chips.
- Messenger - for processing text-based messages from the computer
- Metro - help you time actions at regular intervals
- MsTimer2 - uses the timer 2 interrupt to trigger an action every N milliseconds.
- OneWire - control devices (from Dallas Semiconductor) that use the One Wire protocol.
- PS2Keyboard - read characters from a PS2 keyboard.
- Servo - provides software support for Servo motors on any pins.
- Servotimer1 - provides hardware support for Servo motors on pins 9 and 10
- Simple Message System - send messages between Arduino and the computer
- SSerial2Mobile - send text messages or emails using a cell phone (via AT commands over software serial)
- TextString - handle strings
- TLC5940 - 16 channel 12 bit PWM controller.
- X10 - Sending X10 signals over AC power lines
边栏推荐
猜你喜欢
随机推荐
全栈---JSONP
担心的事情
自定义RunTimeException工具类
容联云发送验证码
【深度学习】基于tensorflow的小型物体识别训练(数据集:CIFAR-10)
PHICOMM(斐讯)N1盒子 - Armbian5.77(Debian 9)刷入EMMC
WRF-Chem模式调试、运行、结果后处理等遇到的各种问题
2022年8月2日——使用idea搭建servlet+jsp项目
全栈---CORS
openCV第一篇
南瓜科学新品上线 开辟益智玩具新世界
公司封装方式导出excel过程
复杂多层布局的初级智能文本提示器
”QSqlDatabasePrivate::removeDatabase: connection ‘test-connect‘ is still in use“数据库多次打开报错
OpenWRT设置ipv6网络
华为防火墙双机热备技术:HRP、VGMP、VRRP,三大技术值得一学!
Guidelines for the use of SVA in UVM
UVM中SVA使用指南
高并发基石:多线程、守护线程、线程安全、线程同步、互斥锁,一文扫尽!...
浅谈敏捷开发