创客百科

姿势共享,有节操无门槛参与的创客百科,创客动力之源 \ (^_^) /

用户工具

站点工具


arduino:libraries:irremote_irsend

IRsend irsend

描述

创建一个发射器对象。取决于本库使用哪个定时器,发射器必须连接到固定的引脚。 例如Arduino UNO在默认设置下使用的是数字引脚3

语法

IRsend irsend;

参数

无。

返回值

无。

例子

/*
 * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
 * An IR LED must be connected to Arduino PWM pin 3.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */
 
#include <IRremote.h>                    // 调用IRRemote库
 
IRsend irsend;                           // 定义发射器
 
void setup()
{
  Serial.begin(9600);
}
 
void loop() {
  if (Serial.read() != -1) {
    for (int i = 0; i < 3; i++) {
      irsend.sendSony(0xa90, 12); // Sony TV 电源开关编码
      delay(40);
    }
  }
}

注释

本代码实现当电脑串口收到任意字符一个字符则发送的一条Sony电视机电源开/关编码,让Arduino可以打开或关闭电视机。(请注意,根据其协议,SONY编码必须发送3次。

返回IRremote目录

本页面的其他翻译:
arduino/libraries/irremote_irsend.txt · 最后更改: 2016/12/25 22:15 (外部编辑)