I've got a setup going with a arduino uno, and a nano, and it's been working fine before, but I turned it on a few days ago and after some testing I found that the nano stopped sending data (receives data fine from what I could tell using the GettingStarted_CallResponse sketch). The wiring is fine as far as I can tell as it is the same as many examples, which work on my uno. I output the radio data and am not sure what it all means. Obviously all the 0's are not good, but I'm not sure how to fix it.
STATUS = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1 = 0x0000000000 0x0000000000
RX_ADDR_P2-5 = 0x00 0x00 0x00 0x00
TX_ADDR = 0x0000000000
RX_PW_P0-6 = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x00
RF_CH = 0x00
RF_SETUP = 0x00
CONFIG = 0x00
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01
CRC Length = Disabled
PA Power = PA_MIN
Here's the Transmitter Code:
#include <SPI.h>
#include <RF24.h>
#include <printf.h>
int lxpin = 2;
int lypin = 3;
int rxpin = 0;
int rypin = 1;
double lx = 0;
double ly = 0;
double rx = 0;
double ry = 0;
int left_bumper = 0;
int right_bumper = 0;
int blue = 0;
int red = 0;
int yellow = 0;
int green = 0;
RF24 radio(8,9);
const uint64_t pipe = 0xE6E6E6E6E6E6; // Needs to be the same for communicating between 2 NRF24L01
float data[10];
void setup() {
Serial.begin(9600);
radio.begin();
printf_begin();
radio.openWritingPipe(pipe);
radio.stopListening();
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(18, INPUT_PULLUP);
pinMode(19, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
radio.printDetails();
}
void loop() {
lx = -mapJoystick(analogRead(lxpin));
ly = mapJoystick(analogRead(lypin));
rx = mapJoystick(analogRead(rxpin));
ry = -mapJoystick(analogRead(rypin));
left_bumper = digitalRead(4);
right_bumper = digitalRead(9);
blue = digitalRead(5);
red = digitalRead(18);
green = digitalRead(19);
yellow = digitalRead(6);
data[0] = lx;
data[1] = ly;
data[2] = rx;
data[3] = ry;
data[4] = left_bumper;
data[5] = right_bumper;
data[6] = blue;
data[7] = red;
data[8] = green;
data[9] = yellow;
radio.write(&data, sizeof(data));
}
float mapJoystick(int value) {
return fmap(value, 0, 1023, -1, 1);
}
float fmap(float x, float a, float b, float c, float d){
return x/(b-a)*(d-c)+c;
}
(I omitted the sensor outputs for readability)
When running the GettingStarted_CallResponse sketch, the transmitter says it failed to send, but if I switch the programs on my uno and nano it works fine. So to summarize my problem, I think that the nano is not working right while sending data, but I cannot see why.