/*
14CORE NRF24L01 MASTER CONTROLLER/TRANSMITTER
*/
#include <SPI.h> //Include SPI Code Library which can be downloaded below
#include <nRF24L01.h> //Include NRF24L01 Code Library which can be downloaded below
#include <RF24.h> //Inlcude NRF24 Code Library which can be downloaded below
byte msg[1];
int pir = 3;
int value = 0;
RF24 radio(7,8); // The NRF24L01 Pin CE and Pin CSN
const uint64_t pipe = 0xA8E8F0F0E1LL; // Communication Pip Address
void setup(void){
pinMode(pir, INPUT);
Serial.begin(9600); // Start Serial Communication at baud rate 9600
Serial.println("Radio begin");
delay(500);
radio.begin();
radio.openWritingPipe(pipe); // Open Communication Pipe
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
if (!radio.begin()) {
Serial.println(F("radio hardware not responding!"));
while (1) {} // hold program in infinite loop to prevent subsequent errors
}
}
void loop(){
value = digitalRead(pir);
if(value == HIGH){ // When the push button has been press it will send radio signal to the RX to turn the LED into HIGH
delay(2);
msg[0] = 111; // Send the 111 to the reciever
radio.write(msg,1);
Serial.println("Transmitting");
delay(100);
}
if(value == LOW){ // When the push button has been press it will send radio signal to the RX to turn the LED into HIGH
delay(2);
Serial.println("idle");
delay(100);
}
else{
Serial.println("idle");
delay(100);
}
}
//reference
//nRF24L01
//https://m.blog.naver.com/roboholic84/221139363425
//https://www.14core.com/wiring-the-nrf24l01-2-4ghz-radio-as-remote-switching/
//https://blog.naver.com/twophase/221122054270
//https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=twophase&logNo=221122351663
//https://m.blog.naver.com/twophase/221132324612
//PIR
//https://fishpoint.tistory.com/6399
//Ultra sonic
//https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=boilmint7&logNo=220926404472
and here's the result. Stil I have no idea what did I wrong..
can you help me?
If you have a problem with your PIR sensor, then you need to debug the code for the PIR sensor. Print the value returned from the pir sensor each time it is read and see if it changes from low to high and back to low.
I moved your topic to an appropriate forum category @cloveraid.
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
/*
14CORE NRF24L01 MASTER CONTROLLER/TRANSMITTER
*/
#include <SPI.h> //Include SPI Code Library which can be downloaded below
#include <nRF24L01.h> //Include NRF24L01 Code Library which can be downloaded below
#include <RF24.h> //Inlcude NRF24 Code Library which can be downloaded below
byte msg[1];
int pir = 3;
int value = 0;
RF24 radio(7, 8); // The NRF24L01 Pin CE and Pin CSN
const uint64_t pipe = 0xA8E8F0F0E1LL; // Communication Pip Address
void setup(void) {
pinMode(pir, INPUT);
Serial.begin(9600); // Start Serial Communication at baud rate 9600
Serial.println("Radio begin");
delay(500);
radio.begin();
radio.openWritingPipe(pipe); // Open Communication Pipe
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
if (!radio.begin()) {
Serial.println(F("radio hardware not responding!"));
while (1) {} // hold program in infinite loop to prevent subsequent errors
}
}
void loop() {
if (digitalRead(pir)) { // When the push button has been press it will send radio signal to the RX to turn the LED into HIGH
msg[0] = 111; // Send the 111 to the reciever
radio.write(&msg, 1);
Serial.println("Transmitting");
}
else Serial.println("idle");
delay(100);
}
//reference
//nRF24L01
//https://m.blog.naver.com/roboholic84/221139363425
//https://www.14core.com/wiring-the-nrf24l01-2-4ghz-radio-as-remote-switching/
//https://blog.naver.com/twophase/221122054270
//https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=twophase&logNo=221122351663
//https://m.blog.naver.com/twophase/221132324612
//PIR
//https://fishpoint.tistory.com/6399
//Ultra sonic
//https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=boilmint7&logNo=220926404472