当前位置:网站首页>【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
边栏推荐
猜你喜欢
随机推荐
”QSqlDatabasePrivate::removeDatabase: connection ‘test-connect‘ is still in use“数据库多次打开报错
visual studio 2012 为啥这么优秀
PHICOMM(斐讯)N1盒子 - Armbian5.77(Debian 9)刷入EMMC
数据中台建设(八):数据服务体系建设
Incorrect datetime value: ‘2022-01-01‘ for function str_to_date
OpenWRT设置ipv6网络
pytest:如何调用 pytest
一个人的精力
ssh(sshd)安全配置
monkey 压测
全栈---JSONP
自己做的选择
8-jwt工具类
粘包与拆包
暴力递归到动态规划 08(小马走象棋)
initramfs详解----设备文件系统
Qt在选择MSVC 编译器的时候,无法识别出M_PI的问题处理
20、商品微服务-web层实现
Greenplum database failure analysis, can not listen to the port
v-if、v-else、v-elseif v-show v-for









