0
我试图通过我的射频模块发送信息,当我试图发送信号时我收到信息说我收到信号但我没有收到任何信息行,但没有信息被它传递...
//Reciever Code (Leonardo)
的#include收到Arduino射频信号,但没有收到任何信息
void setup()
{
Serial.begin(9600);
pinMode(13,OUTPUT);
digitalWrite(13,LOW);
vw_setup(2000);
vw_set_rx_pin(7);
vw_rx_start();
}
void loop()
{
Serial.println("nothing");
uint8_t buflen = VW_MAX_MESSAGE_LEN;
uint8_t buf[buflen];
if (vw_get_message(buf, &buflen)){
Serial.print("got it");
delay(1000);
}
if(vw_get_message(buf, &buflen))
{
for(int i = 0;i < buflen;i++)
{
Serial.println(buf[i]);
if(buf[i] == '0')
{
digitalWrite(13,HIGH);
}
else if(buf[i] == '1')
{
digitalWrite(13,HIGH);
}
}
}
}
我对reciver串行监视器读取
nothing got it128 nothing nothing nothing nothing nothing nothing nothing nothing nothing nothing nothing nothing got it
我的发送源代码是
#include <VirtualWire.h>
void setup()
{
Serial.begin(9600);
vw_setup(2000);
vw_set_tx_pin(7);
}
void loop()
{
if(1==1)
{
char c = '1';
if(c == '1')
{
vw_send((uint8_t *)c, 1);
Serial.println("SENDING");
}
else if(c == '0')
{
vw_send((uint8_t *)c, 1);
}
}
}
和我的模块看起来像这样