Vraj
Advanced Member level 4
i am facing some problems with coding .kindly suggest me.
hello,
i am facing some coding problem with this arduino nrf24l01 code.
here is the receiver code
and here is transmitter code
i think there is problem with receiver side
because i can see the values of analog read on serial monitor.
hello,
i am facing some coding problem with this arduino nrf24l01 code.
here is the receiver code
Code:
#include<SPI.h>
#include"RF24.h"
RF24 radio(7, 8);
byte addresses[][6] = {"0"};
struct package
{ float vraj = 1;
};
typedef struct package;
package data;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
radio.begin();
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate(RF24_1MBPS);
radio.setChannel(115);
radio.openReadingPipe(1, addresses[0]);
radio.startListening();
delay(100);
}
void loop() {
Serial.println("i m top");
delay(1000);
radio.startListening();
if (radio.available())
{ while (radio.available())
{
radio.write(&data, sizeof(data));
Serial.println("i m here");
}
radio.stopListening();
analogWrite(3, data.vraj);
Serial.println(data.vraj);
}
else
{ Serial.println("no");
} delay(1000);
}
and here is transmitter code
Code:
#include<SPI.h>
#include"RF24.h"
RF24 radio(7,8);
byte addresses[][6]={"0"};
struct package
{ float vraj=1;
};
typedef struct package;
package data;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
radio.begin();
radio.setPALevel(RF24_PA_MIN);
radio.setDataRate(RF24_1MBPS);
radio.setChannel(115);
radio.openWritingPipe(addresses[0]);
delay(100);
radio.startListening();
}
void loop() {
// put your main code here, to run repeatedly:
radio.write(&data,sizeof(data));
Serial.println(data.vraj);
data.vraj=map(analogRead(3),0,1023,0,255);
delay(1000);
}
i think there is problem with receiver side
because i can see the values of analog read on serial monitor.