RF24 programming problem

Ive been using the NRF24L01 transceivers and two Arduino uno boards to try and get the two boards to talk to each other in a very basic way using a sharp IR distance sensors (which do work properly in the program). Going through the program it works fine untill it hits the radio.write command at which point it seems to freeze up and not continue through the program. Here is the program I’ve been using any help would be greatly appreciated.

#include <SPI.h>
#include “nRF24L01.h”
#include “RF24.h”
int msg[1];
int ir_sensor = A0;
int num = 7;
RF24 radio(9,10);
int sensor_value;
void setup(void){
Serial.begin(9600);
radio.begin();
radio.setRetries(15, 15);
}
void loop(void){
wireless();
wireless2();}

void wireless(){
if(sensor_value > 500){
radio.openWritingPipe(8008135);
radio.stopListening();
msg[0] = num;
radio.write(msg, 1);
}
}
void wireless2(){
sensor_value = analogRead(ir_sensor);
if(sensor_value < 500){
int sensor_value = analogRead(ir_sensor);
radio.openReadingPipe(1,8008135);
radio.startListening();
radio.read(msg, 1);
if(msg[0] == 7){
Serial.println(msg[0]);
Serial.println(“worked”);}
}
}

void loop(void){
  wireless();
  wireless2();}

That looks like crap.

void loop(void)
{
  wireless();
  wireless2();
}

OK. That's better.

Now, how are we supposed to guess what wireless() does? Then, wireless2() just makes you look completely unimaginative. Seriously, the Arduino team doesn't use meaningless names. Why do you?

void wireless(){
    if(sensor_value > 500){

Where have you assigned a value to sensor_value?

  msg[0] = num;
  radio.write(msg, 1);

Store a one byte value in a two byte variable, and then tell the sending function that the variable is one byte in length, causing it to ignore the portion where you stored the data. Hmmm...

Going through the program it works fine untill it hits the radio.write command at which point it seems to freeze up and not continue through the program.

And you know that how?

@maxxgarris3, please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

I can’t tell from your Post whether you have got the nRF24s working in another program and are just having problems with this one.

I got my nRF24s working with this Tutorial

I suggest you use the TMRh20 version of the RF24 library - it solves some problems from the ManiacBug version

The pair of programs in this link may be useful.

…R