2017-08-08 94 views
0

我有一個arduino傳輸器設置與nFR24L01 transever。當我嘗試在arduino mega和arduino uno之間發送數據時,串行監視器顯示垃圾。Arduino串行監視器傳輸數據時顯示垃圾

這裏是我的代碼:

兆:

#include <SPI.h> 
#include <nRF24L01.h> 
#include <RF24.h> 

RF24 radio(7, 8); // CNS, CE 

const byte address[6] = "00001"; 

void setup() { 
    Serial.begin(9600); 
    radio.begin(); 
    radio.openWritingPipe(address); 
    radio.setPALevel(RF24_PA_MIN); 
    radio.stopListening(); 
} 

void loop() { 
    const char text[] = "Hello World, tw"; 
    radio.write(&text, sizeof(text)); 
    delay(500); 
    radio.write("what about this?",15); 
    delay(500); 
} 

歐諾:

#include <SPI.h> 
#include <nRF24L01.h> 
#include <RF24.h> 
RF24 radio(7, 8); // CNS, CE 
const byte address[6] = "00001"; 
void setup() { 
    Serial.begin(9600); 
    delay(1000); 
    Serial.println("Hello to the world."); 
    radio.begin(); 
    radio.openReadingPipe(0, address); 
    radio.setPALevel(RF24_PA_MIN); 
    radio.startListening(); 
} 
void loop() { 
    //delay(1000); 
    if (radio.available()) { 
    char text[32] = ""; 
    radio.read(&text, 15); 
    Serial.println(text); 
    } 
} 

My Scematic 提前感謝!

+0

我們需要更多信息才能爲您提供幫助。你可以發佈你的設置的照片或原理圖嗎? – Drue

+0

我在帖子中添加了一個示意圖。希望有所幫助。 –

+0

傳輸工作正常。串口監控是問題 –

回答

1

問題可能是串行監視器處於與代碼和/或收發器不同的速率。

嘗試檢查串行監視器的波特率並將其設置爲9600.

+0

謝謝!這幫助我分配 –