Good morning . I have a short program that works fine with UNO's but after three days can't get MEGA to play ball.
I am using a NRFL24L01 to link two boards, I am using the correct pins 50,51,52 with 7 and 8 on the MEGA.
The power supplies are stable and have decoupling capacitors next to the RF units. Pin 53 is taken LOW.
I have looked at as much as i can but can't explain why it is not working. Is there something in the library which is not combatable?
Code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
//#define button1 3
//#define button2 5
#define SS 53
RF24 radio(7, 8); // CE, CSN
const byte addresses[][6] = {"00001", "00002"};
int button1State = 0;
int button2State = 0;
void setup() {
pinMode(SS, OUTPUT);
digitalWrite(SS, LOW);
radio.begin();
radio.openWritingPipe(addresses[1]); // 00002
radio.openReadingPipe(1, addresses[0]); // 00001
radio.setPALevel(RF24_PA_MIN);
}
void loop() {
delay(5);
radio.stopListening();
int potValue = analogRead(A0);
int angleValue = map(potValue, 0, 1023, 0, 180);
radio.write(&angleValue, sizeof(angleValue));
delay(5);
/* button1State = digitalRead(button1);
radio.write(&button1State, sizeof(button1State));
button2State = digitalRead(button2);
radio.write(&button2State, sizeof(button2State));*/
}
Any advice please.