BASIC4MCU | 질문게시판 | nrf24l01 센서 송신실패 문의
페이지 정보
작성자 대학생초보 작성일2018-06-13 22:25 조회7,783회 댓글0건본문
이 소스를 적용시켰는데 시리얼모니터에 send faild이 계속 뜨는데
어떤 부분이 잘못됬는지 잘모르겟어요
수정해야될 부분을 알려주세요
부탁드립니다.
//Libraries for NRF24L01+ module.
#include <SPI.h>
#include <RF24.h>
//RF24 object with two pins defined with arguments. CE: 7, CSN: 8
RF24 radio(7, 8);
//Address of the pipe. 40 bit long, you can choose this freely.
//Remember to use different address in different projects.
long long address = 0x1234ABCDEFLL;
int sensorPin = 6;
int led;
//Variable that selects whether the circuit is sender (1) or receiver (0)
bool sender = 1;
void setup() {
//Start the radio
Serial.begin(9600);
radio.begin();
if (sender) { //If sender
radio.openWritingPipe(address);
//RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX
//NRF24L01: -18dBm, -12dBm,-6dBM, and 0dBm
radio.setPALevel(RF24_PA_LOW);
radio.stopListening();
} //If sender
else { //If receiver
//Open reading pipe with given address and start listening for incoming data
radio.openReadingPipe(1, address);
radio.startListening();
} //If receiver
}
void loop() {
if (sender) { //If sender
//Get temperature from the sensor
int reading = digitalRead(sensorPin);
led = reading;
//Send the temperature wirelessly, print error if failed
if (!radio.write(&led, sizeof(led))) {
Serial.println(F("Sending failed"));
}
delay(1000);
} //If sender
else { //If receiver
//If data is available in radio's buffer
if(radio.available()) {
//While the data is available...
while (radio.available()) {
//Update temperature -variable with data from the radio module
radio.read(&led, sizeof(led));
}
Serial.println(led);
}
} //If receiver
}
댓글 0
조회수 7,783등록된 댓글이 없습니다.