my NRF24l01+ only work after reseting arduino and it can only transmit and recieve 1 data i have this problem for days and i dont know how to fix it, here is the code
transmitter
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
RF24 radio(7,8);
const uint64_t pipe = 0xE8E8F0F0E1LL;
int value;
void setup() {
// put your setup code here, to run once:
digitalWrite(10,HIGH);
radio.begin();
radio.setChannel(100);
radio.openWritingPipe(pipe);
radio.stopListening();
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
value = analogRead(A0);
Serial.println(value);
radio.write(&value, sizeof(int));
}
reciever
#include<SPI.h>;
#include<Servo.h>;
#include "nRF24L01.h"
#include "RF24.h"
RF24 radio(7,8);
const uint64_t pipe = 0xE8E8F0F0E1LL;
int pos;
int hold;
Servo servo;
void setup() {
// put your setup code here, to run once:
digitalWrite(10,HIGH);
radio.begin();
radio.setChannel(100);
radio.openReadingPipe(1, pipe);
radio.startListening();
servo.attach(3);
}
void loop() {
// put your main code here, to run repeatedly:
if(radio.available())
{
radio.read(&hold, sizeof(hold));
}
pos = map(hold, 0, 1023, 0, 180);
servo.write(pos);
}
what im trying to make is a potentiometer controling a servo for steering my RC car, i use arduino uno for both the transmitter and reciever.