创客百科

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

用户工具

站点工具


arduino:libraries:irremote_sendraw

irsend.sendRaw()

描述

发射一组原始时长编码。常规而言,我们所获得的时长缓存(rawbuf)和时长长度(rawlen)需要将红外编码接收多次并取其平均值作为结果。 这些调整是不可避免的!频率(frequency)参数往往取决于接收器的滤波频率?。38是最常见的设定。

语法

irsend.sendRaw(rawbuf, rawlen, frequency);

参数

rawbuf: 保存红外脉冲时长的数组。
rawlen: 保存在数组中时长的数量。
frequency: 发射频率。常见的有38,40等。

返回值

无。

例子

//not test yet!!!!!!!! - Leo
 
#include <IRremote.h>                    // 调用IRRemote库
 
IRsend irsend;                           // 定义发射器
 
// 定义一组原始时长数组,等值为NEC协议的0x12345678
unsigned int sendbuf[] = { /* NEC format */
  9000, 4500,
  560, 560, 560, 560, 560, 560, 560, 1690, /* 1 */
  560, 560, 560, 560, 560, 1690, 560, 560, /* 2 */
  560, 560, 560, 560, 560, 1690, 560, 1690, /* 3 */
  560, 560, 560, 1690, 560, 560, 560, 560, /* 4 */
  560, 560, 560, 1690, 560, 560, 560, 1690, /* 5 */
  560, 560, 560, 1690, 560, 1690, 560, 560, /* 6 */
  560, 560, 560, 1690, 560, 1690, 560, 1690, /* 7 */
  560, 1690, 560, 560, 560, 560, 560, 560, /* 8 */
  560};
 
 
void setup()
{
  Serial.begin(9600);
}
 
void loop() {
  if (Serial.read() != -1) {          // 如果串口接收到任意字符
      irsend.sendRaw(sendbuf, 32, 38); // 发射原始时长的红外编码
  }
}

注释

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