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);
}
}
}
和我的模塊看起來像這樣