So, I have stripped things down to the barest to troubleshoot. Here is what I have:
Arduino Pro Mini:
Pin (RAW) = +5V (Scavenged wall plug USB charger (2A))
Pin (VCC) = Pin VCC on NRF24L01
Pin GND = GND & Pin GND on NRF24L01
D9 = Pin CE on NRF24L01
D10 = Pin CS on NRF24L01
D11 = Pin MOSI on NRF24L01
D12 = Pin MISO on NRF24L01
D13 = Pin SCK on NRF24L01
D8 = 20K Resistor connected to GND & Switch connected to VCC
D2 = 20K Resistor connected to GND & Switch connected to VCC
I originally had this set up on D8 only. Got the below described crazy results, so I thought "Maybe the RF24 code is messing with D8." So, I connected the same on D2. SAME RESULTS.
CODE:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(9,10); // CE-Pin, CS-Pin
const byte addresses[][7] = {"Master","Slave"};
const int master = 0;
const int slave = 1;
const int myRole = master;
const int otherRole = slave;
const int switchOnePin = 2; // pin the switch is connected to
const int switchTwoPin = 8; // pin the switch is connected to
int switchOneState = 0; // current state of the switch
int switchTwoState = 0; // current state of the switch
void setup() {
// Setup Serial
Serial.begin(9600);
printf_begin();
printf("\n\rRF24-Test\n\r");
// Setup and configure rf radio
//radio.begin(); // Start up the radio
//radio.setAutoAck(1); // Ensure autoACK is enabled
//radio.setRetries(15,15); // Max delay between retries & number of re tries
//radio.openReadingPipe(1,addresses[otherRole]);
//radio.openWritingPipe(addresses[myRole]);
//radio.startListening();
//radio.stopListening();
//radio.end();
// Set Modes of Pins
pinMode(switchOnePin, INPUT);
pinMode(switchTwoPin, INPUT);
}
void loop(void){
switchOneState = digitalRead(switchOnePin);
switchTwoState = digitalRead(switchTwoPin);
printf("\n\rswitchOneState: %d\n\r",switchOneState);
printf("\n\rswitchTwoState: %d\n\r",switchTwoState);
delay(500);
}
Running the code as it is WORKS PERFECTLY. Setting either switch to on or off changes the value of the variable between 0 and 1 respectively. See the expected output on the serial connection as you change the switch states.
The moment I uncomment the "radio.begin();" line (and any other radio lines, but only need to uncomment that first line), both switch states start at 1 upon boot and never change regardless of the actual switch states.
In other words, if I enable the radio, it is as if both D8 and D2 become OUTPUTs and are hard coded to HIGH.
I have tried the other pins too (D3-D7) and get the same result.
Has anyone successfully gotten a NRF24L01+ to work on a Arduino Pro Mini or is it incompatible with the APM?
Or, more importantly, does anyone have a clue what is going on or how to fix it?
Any and all help is GREATLY appreciated. I'm going nuts here.
Thank you.
~Robert
Moderator: added [code]...[/code]
tags