my NRF24l01 wont work when i press a button, for transmitter i use uno, for reciever i use nano
transmitter
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(5,3);
const byte address[6] = "00002";
void setup() {
// put your setup code here, to run once:
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_HIGH);
radio.stopListening();
pinMode(7,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(7) == HIGH)
{
int code = 1;
radio.write(&code, sizeof(code));
}
}
reciever
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(3,5);
const byte address[6] = "00002";
void setup() {
// put your setup code here, to run once:
radio.begin();
radio.openReadingPipe(0,address);
radio.setPALevel(RF24_PA_HIGH);
pinMode(6,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
radio.startListening();
if(radio.available())
{
int code;
radio.read(&code, sizeof(kode));
if(code == 1)
{
digitalWrite(6,HIGH);
}
}
}