NRF24L01 pair with HC-SR04 input

Hey guys and gals,

Hopefully I'm posting this in the right subforum, if not I sincerely apologize. Also I'm still a bit of a novice, so please excuse my ignorance (it isn't intentional, I swear).

So here's my setup: I have two Arduino Uno boards, and on each board I have a 2.4GHz NRF24L01 chip. On the Tx board, I also have a HC-SR04 ultrasonic proximity sensor. On the Rx board, I currently have a series of 6 LEDs - 2 red, 2 yellow, 2 green. Tomorrow I should be receiving a Mini Vibrating Motor and a corresponding Haptic Control Board, to replace the LEDs - which I'll expand on in a second.

Here's the plan: My Tx board will be set at a static point in space. My Rx board will be mounted on a wearable device, like a headband or something. The person wearing the headband will begin by standing directly in front of the ultrasonic rangefinder, then moving in a linear fashion away from the sensor. As the person reaches specific distances from the sensor, the mini vibrating motor attached to the Rx board will vibrate with increasing intensity, such that the person can get a general sense of how far away they are.

Now here's what I have and understand (fundamentally, at least) thus far:

  1. The HC-SR04 sensor on the Tx board is working well, and I have it coded to light up LEDs on the same board in response to how high the distance reading from the sensor is.

  2. The Tx board and Rx board have been made to identify each other and transmit signals through the mounted NRF24L01 chips.

Here's what I do not quite understand (and not for lack of searching - I know there's likely a tutorial out there for exactly what I want to do, perhaps I'm just using the wrong search parameters and phrases?):

  1. I have seen methods of transmitting messages from one board to another with the RF chips, but I have not yet wrapped my head around how to get my Tx board to send a command to my Rx board, essentially saying "If I get a distance reading of 10 feet, start vibrating the motor at a low power. If I get a distance reading of 15 feet, increase the motor power by 1 interval. Continue this pattern for every five foot increase."

  2. I'm not quite fluent in Arduino coding yet. I began by testing each component separately, using tutorials I found online. As such, I currently have one sketch that runs the ultrasonic sensor and LED matrix (on the same board), and another sketch (rather, 2 sketches) that control the RF chips and allow them to communicate. When using the RF chips, assuming I was able to convey my intentions effectively, I am thinking I would need the sketch for the Tx board to just include the RF Tx code and the US sensor code; while the sketch for the Rx board would include the RF Rx code and the Haptic Control Board code (containing the vibrating motor code). I know this part of my post belongs in a different part of the forum but I'm just looking for a quick yes/no/maybe at this point.

Last part, I promise. I know it would be infinitely simpler to just mount the US sensor on the headband and ditch the wireless aspect, but I am thinking I'll have to be next to the US sensor, adjusting the direction it is facing, just in case the person with the Rx headband strays from a linear path - if that makes sense. To make this really long story (sorry I just wanted to be thorough) short, I am looking for some guidance with sending commands from one Arduino board to another using these RF chips; this command tells the Rx board to vibrate a motor at a specific intensity that corresponds to the distance readings from a US sensor on the Tx board.

Goodness me I hope that came out right. Thanks in advance everybody!

how to get my Tx board to send a command to my Rx board,

The TX board does not need to make decisions, it need only send the distance information. Make all the decisions on the RX board. That way it is much easier to code and test.

jremington: The TX board does not need to make decisions, it need only send the distance information. Make all the decisions on the RX board. That way it is much easier to code and test.

Ditto.

Just send the distance variable.