BASIC4MCU | 질문게시판 | 답변 : nrf24l01 센서 송신실패 문의
페이지 정보
작성자 master 작성일2018-06-13 23:00 조회20,129회 댓글5건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=1839
작성일
작성일
작성일
작성일
본문
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2018-06-13 오후 11:03:06// by Ok-Hyun Park////Libraries for NRF24L01+module.#include <SPI.h>#include <RF24.h>RF24 radio(7,8); // CE: 7,CSN: 8long long address=0x1234ABCDEFLL; // Address of the pipe.40 bit long//int sensorPin=6;int led;bool sender=1; //Variable that selects whether the circuit is sender(1)or receiver(0)//void setup(){Serial.begin(9600); //Start the radioradio.begin();if(sender){radio.openWritingPipe(address);radio.setPALevel(RF24_PA_LOW); //RF24_PA_MIN,RF24_PA_LOW,RF24_PA_HIGH and RF24_PA_MAX //NRF24L01:-18dBm,-12dBm,-6dBM,and 0dBmradio.stopListening();}else{radio.openReadingPipe(1,address); //Open reading pipe with given address and start listening for incoming dataradio.startListening();}}//void loop(){if(sender){int reading=digitalRead(sensorPin); //Get temperature from the sensorled=reading;if(!radio.write(&led,sizeof(led))){ Serial.println(F("Sending failed")); } //Send the temperature wirelessly,print error if faileddelay(1000);}else{if(radio.available()){ //If data is available in radio's bufferwhile(radio.available()){ //While the data is available...radio.read(&led,sizeof(led)); //Update temperature-variable with data from the radio module}Serial.println(led);}}}
if(!radio.write(&led,sizeof(led))){ Serial.println(F("Sending failed")); }
전송실패 메시지인데요?
수신측이 켜있는 상태인가요?
댓글 5
조회수 20,129대학생초보님의 댓글
대학생초보 작성일네 수신측 켜져있는상태 입니다. 다시해보니 시리얼 모니터에 0,1,2,3이 계속 반복적으로 뜨기만하고 led점등이 안되네요... 왜그럴까요??
master님의 댓글
master
수신측 소스도 첨부해보세요
대학생초보님의 댓글
대학생초보
bool sender = 0; << 이부분만 다릅니다.
//Variable that selects whether the circuit is sender(1)or receiver(0)
이렇게 되있어서 1넣으면 송신 0넣으면 수신으로 되는것으로 알고있는데 수신부는 따로 작성을 해야되는건가요??
master님의 댓글
master
LED 점등이 안된다고 했는데요
LED 핀이 몇번인지 찾아보고
LED 출력 설정과 LED 출력하는 코드가 어느 것인지 찾아보세요
대학생초보님의 댓글
대학생초보
https://kocoafab.cc/tutorial/view/578
이사이트 참고해서 소스입력했는데 혹시 어떤부분이 잘못됬는지 봐주실수있나요??