arduino 编程语言(2)

2020-03-29 12:42

也有效和正确

The map() function uses integer math so will not generate fractions, when the math might indicate that it should do so. Fractional remainders are truncated, and are not rounded or averaged.

map()函数使用整型,所以不会产生分数,分数将会被截去,并不是全面的或平均值(?)

Parameters 参数

value: the number to map

给map的值

fromLow: the lower bound of the value's current range

值现在的下界

fromHigh: the upper bound of the value's current range

值现在的上界

toLow: the lower bound of the value's target range

值目标范围的下界

toHigh: the upper bound of the value's target range

值目标范围的上界

Returns 返回值

The mapped value.

映射的值 Example

void setup() {}

void loop() {

int val = analogRead(0); //读取0口的值

val = map(val, 0, 1023, 0, 255);//从0-1023映射到0-255 analogWrite(9, val);//把映射后的值写给9口 }

attachInterrupt(中断通道, 中断函数, 触发方式);

中断函数就是你要去执行的函数,这个函数不能带任何参数,且没有返回类型 中断模式就是你的中断触发方式。在大多数arduino上有以下四种触发方式: LOW 低电平触发

CHANGE 电平变化,高电平变低电平、低电平变高电平 RISING 上升沿触发

FALLING 下降沿触发

HIGH 高电平触发(该中断模式仅适用于Arduino due) 各种型号Arduino外部中断引脚

外部中断在不同的Arduino型号上位置也不同,只有外部中断发生在以下端口,Arduino才能捕获到,以下例举了常见的几种型号的外部中断引脚标号。 型号 int.0 int.1 int.2 int.3 int.4 int.5 UNO\\Ethernet 2 3

Mega2560 2 3 21 20 19 18 Leonardo 3 2 0 1 Due 所有IO口均可 http://www.arduino123.com/


arduino 编程语言(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:电大作业-现代科技基础知识

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: