当前位置:网站首页>【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
边栏推荐
- 2022-08-02:小红拿到了一个大立方体,该大立方体由1*1*1的小方块拼成,初始每个小方块都是白色。 小红可以每次选择一个小方块染成红色, 每次小红可能选择同一个小方块重复染色, 每次染色以后,
- 自己做的选择
- .NET in-depth analysis of the LINQ framework (four: IQueryable, IQueryProvider interface details)
- 全栈---JSONP
- 7-Redis工具类
- 容联云发送验证码
- win下使用vscode+wsl2
- JVM内部结构图及各模块运行机制总结
- 236. The binary tree in recent common ancestor
- 如何备考PMP才能一次通过?
猜你喜欢
随机推荐
常用工具链和虚拟环境-WSL
SAP ABAP OData 服务如何支持修改(Update)操作试读版
关于提高企业网络安全意识
mysql容器数据卷持久化
梅科尔工作室-14天华为培训三
UVM中SVA使用指南
Brute force recursion to dynamic programming 07 (516. Longest palindrome subsequence)
暴力递归到动态规划 06 (剑指 Offer II 095. 最长公共子序列)
国标GB28181协议EasyGBS平台项目现场通知消息过多导致系统卡顿该如何解决?
嵌入式开发:嵌入式基础——’ ’和” ”的区别
visual studio 2012 为啥这么优秀
PHICOMM(斐讯)N1盒子 - Armbian5.77(Debian 9)基本配置
10. SAP ABAP OData 服务如何支持修改(Update)操作
易购数码类电商商城网页设计与实现项目源码
从 npm 切换到 pnpm,真香!
async-await
如何备考PMP才能一次通过?
44LVS负载均衡群集-NAT
mysql binlog日期解析成yyyy-MM-dd
可信的SSL证书颁发机构有哪些