Arduino教程31.Arduino delayMicroseconds()函数

delayMicroseconds()函数接受单个整数(或数字)参数。此数字表示时间,以微秒为单位。一毫秒内有一千微秒,一秒内有一百万微秒。

目前,可以产生精确延迟的最大值是16383。这可能会在未来的Arduino版本中改变。对于超过几千微秒的延迟,应该使用delay()函数。

delayMicroseconds()函数语法

delayMicroseconds (us) ;

其中, us 是要暂停的微秒数(无符号整型)。

例子

/* ;ED闪烁
   * ------------
   * 打开和关闭连接到数字的发光二极管(LED)
   * 间隔一秒*
*/

int ledPin = 13; // LED connected to digital pin 13

void setup() {
   pinMode(ledPin, OUTPUT); // sets the digital pin as output
}

void loop() {
   digitalWrite(ledPin, HIGH); // 打开LED灯
   delayMicroseconds(1000); // 等待 1000 us
   digitalWrite(ledPin, LOW); // 关闭LED灯
   delayMicroseconds(1000); // 等待 1000 us
}

发布者:suiyublg,转转请注明出处:https://huibian.net/1013-4/

赞 (0)
suiyublg的头像suiyublg
上一篇 2017年3月29日 18:18
下一篇 2017年3月29日 18:20

相关推荐

  • Arduino教程28.Arduino 嵌套循环

    C语言允许你在另一个循环内使用一个循环。下面的例子说明了这个概念。 嵌套循环语句语法 for ( initialize ;control; increment or decrement) { // statement block for ( initialize ;control; increment or decrement) { // statement…

    2017年3月25日
    68700
  • Arduino教程22.Arduino If … else if … else语句

    if 语句后面可以跟随一个可选的 else if … else 语句,其对于测试各种条件非常有用。 当使用 if … else if … else 语句时,请记住: if … else if … else语句 if (expression_1) { …

    2017年3月24日
    63900
  • Arduino教程32.Arduino millis()函数

    此函数用于返回Arduino板开始运行当前程序时的毫秒数。这个数字在大约50天后溢出,即回到零。 millis()函数语法 millis () ; 此函数从程序开始处返回毫秒。 例子 unsigned long time; void setup() { Serial.begin(9600); } void loop() { Serial.print(“Tim…

    2017年3月29日
    67000
  • Arduino函数库04.Arduino 数学库

    Arduino数学库(math.h)包含了许多用于操作浮点数的有用的数学函数。 库中的宏 以下是在标题math.h中定义的宏: 宏 值 描述 M_E 2.7182818284590452354 常数e。 M_LOG2E 1.4426950408889634074/* log_2 e */ e以2为底的对数。 M_1_PI 0.3183098861837906…

    2017年4月3日
    75601
  • Arduino教程18.Arduino 按位运算符

    假设变量A为60,变量B保持13,则: 运算符名称 运算符简写 描述 例子 and(与) & 如果同时存在于两个操作数中,二进制AND运算符复制一位到结果中。 (A & B) 将得出12,即0000 1100 or(或) | 如果存在于任一操作数中,二进制OR运算符复制一位到结果中。 (A | B)将得出61,即0011 1101 …

    2017年3月23日
    64100

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
欢迎大家来到大雄学编程!