找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2699|回复: 1
打印 上一主题 下一主题
收起左侧

arduino 433M无线遥控接收问题求助

[复制链接]
跳转到指定楼层
楼主
ID:389836 发表于 2019-1-7 12:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
433遥控器,我用库RCSwitch里面接收例程,收到信号的value值是:

遥控器按键A:Received 5264652 / 24bit Protocol: 1
遥控器按键B:Received 5264688 / 24bit Protocol: 1
以上是串口读取出的数据。

#include <RCSwitch.h>
int led=13;

RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  pinMode(led,OUTPUT);
  mySwitch.enableReceive(0);  // Receiver on inerrupt 0 => that is pin #2
}

void loop() {
  if (mySwitch.available()) {

    int value = mySwitch.getReceivedValue();

    if (value == 0) {
      Serial.print("Unknown encoding");
    } else {
      Serial.print("Received ");
      Serial.print( mySwitch.getReceivedValue() );
      Serial.print(" / ");
      Serial.print( mySwitch.getReceivedBitlength() );
      Serial.print("bit ");
      Serial.print("Protocol: ");
      Serial.println( mySwitch.getReceivedProtocol() );
    }
    if(value==5264652){
      digitalWrite(led,HIGH);
          }
    if(value==5264688){
      digitalWrite(led,LOW);
         }

    mySwitch.resetAvailable();
  }
}


以上是例程代码简单修改,就是按键A时,LED亮灯,按键B时,LED灭灯;
实际情况是LED不亮灯也不灭灯,哪位大侠帮我看看问题出在哪里?


我还是放上接收解码的例程吧:
/*
  Simple example for receiving
*/

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(0);  // Receiver on inerrupt 0 => that is pin #2
}

void loop() {
  if (mySwitch.available()) {

    int value = mySwitch.getReceivedValue();

    if (value == 0) {
      Serial.print("Unknown encoding");
    } else {
      Serial.print("Received ");
      Serial.print( mySwitch.getReceivedValue() );
      Serial.print(" / ");
      Serial.print( mySwitch.getReceivedBitlength() );
      Serial.print("bit ");
      Serial.print("Protocol: ");
      Serial.println( mySwitch.getReceivedProtocol() );
    }

    mySwitch.resetAvailable();
  }
}


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:585217 发表于 2019-7-16 16:19 | 只看该作者
你好 怎么发送的放float数据 接收到的只能是int整数
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表