Notifications
Clear all

Wireless joystick for Arduino car with nRF2401+

39 Posts
3 Users
1 Likes
9,969 Views
(@chickenhawk)
Member
Joined: 4 years ago
Posts: 44
Topic starter  

@casey

I was looking at you post

Some others had issues with the Mega?

https://forum.arduino.cc/index.php?topic=71574.0


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

@chickenhawk

Something else that struck me as odd when I looked through Bill's sketches is that unlike the RF24 and RF24Network libraries that I am using. The CE and CSN pins are not set in the sketch and I guess that the MOSI, MISO and SCK pins are all pre-set in the libraries. Therefore substituting the Mega for the Uno just won't work, without adjusting the libraries manually.

Connecting the CE and CSN pins with the same numbers as in Bill's instruction (8 & 10) may work, but only if the library automatically assigns MOSI, MISO and SCK to the correct pins on the Mega!


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

Alternatively, you may just to add this constructor before the setup()

RH_NRF24(8, 53);

Found this in the RH_NRF24.h header file!

Extract:

/// For an Arduino Mega:
/// \code
/// Mega Sparkfun WRL-00691
/// 5V-----------VCC (3.3V to 7V in)
/// pin D8-----------CE (chip enable in)
/// SS pin D53----------CSN (chip select in)
/// SCK pin D52----------SCK (SPI clock in)
/// MOSI pin D51----------SDI (SPI Data in)
/// MISO pin D50----------SDO (SPI data out)
/// IRQ (Interrupt output, not connected)
/// GND----------GND (ground in)
/// \endcode
/// and you can then use the constructor RH_NRF24(8, 53).
///


   
ReplyQuote
(@chickenhawk)
Member
Joined: 4 years ago
Posts: 44
Topic starter  

@pugwash

#include <SPI.h>
#include <RH_NRF24.h>

// Singleton instance of the radio driver
RH_NRF24 nrf24;

RH_NRF24(8, 53);                    

// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

void setup()

Sorry grand son left for school, is this where you want him to put it in the " client sketch " ?


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

@chickenhawk

As you have already created an instance the following is required.

#include <SPI.h>
#include <RH_NRF24.h>

// Singleton instance of the radio driver
RH_NRF24 nrf24;

RH_NRF24 nrf24(8, 53);                    

// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

void setup()

 


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

@chickenhawk

I need my afternoon nap ? 

This is all that is required:

#include <SPI.h>
#include <RH_NRF24.h>

// Singleton instance of the radio driver
RH_NRF24 nrf24(8, 53);                   

// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

void setup()

   
ReplyQuote
(@chickenhawk)
Member
Joined: 4 years ago
Posts: 44
Topic starter  

@pugwash

LOL still morning hear. I will get him to try that when he gets home and school work is done


   
ReplyQuote
(@chickenhawk)
Member
Joined: 4 years ago
Posts: 44
Topic starter  

@pugwash

Many thanks, that got it working.

But I want him to understand why it worked. Not just have people tell him to do this or that.

His answer was that you are telling the nrf24 to use pin 8 and pin 53 to talk back and forth to each other?

 


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

@chickenhawk

That was sheer luck! Your grandson has been leading us on a wild goose chase!

When I looked at the code extract you posted and the code on the DroneBot Website, they do not have the faintest similarity. My guess is that your grandson found another sketch somewhere else and thought it would work one to one, which is not always the case!

Had you uploaded the .ino files, as I requested in my first post, we would have nailed this problem two days ago.

His answer was that you are telling the nrf24 to use pin 8 and pin 53 to talk back and forth to each other?

That is not true, the CE CSN pins are control pins. MOSI and MISO handle the data!

By instantiating the object rf24 with (8, 53) as parameters you are actually overriding the predetermined default values. All the other pins MOSI, MISO and SCK pins must be attached to pin nodes with fixed I/O numbers, determined by whichever microcontroller you are using.


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

@chickenhawk

This document explains what the pin connections are for, see table 2.2.


   
ReplyQuote
(@chickenhawk)
Member
Joined: 4 years ago
Posts: 44
Topic starter  

@pugwash

Sorry the code that we posted was from the first part of the " Wireless joystick for Arduino car with nRF24l01"

" radiohead sample sketch-client & server"

He was working on :

Examples -Radiohead-NRF24-nrf24 server

It has the server send " hello world" and the client replys back " " and hello back to you"

Sorry if we wasted your time we are  just starting out and are struggling to understand all of this


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

@chickenhawk

Apologies, not necessary! We all start at the bottom of the learning curve.

But I must emphasise that when asking for help on a public forum, you must provide the maximum amount of information available, otherwise, we are just guessing!


   
ReplyQuote
(@chickenhawk)
Member
Joined: 4 years ago
Posts: 44
Topic starter  

@pugwash

I now understand that. I 'm trying to get him to go line by line of the  code to understand what each line is saying. I bought him a Sparkfun inventors kit and he has been doing " blink--sweep and the rest " but it seems when he goes on line everyone seems to have there own code or way to do the same things.  And a lot of time he is in way over his head (and way way over mine). When he wanted to do this wireless car I was not going to try to discouraged him. A lot of time people tell him to do this or do that and we just don't understand what they want us to do. And wow,  lord help you if you ask a stupid question. He has had a ruff life already with out people shitting on him for asking questions


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

@pugwash

And wow,  lord help you if you ask a stupid question. He has had a ruff life already with out people shitting on him for asking questions

Unfortunately in real life you do have to learn to be resilient against certain kinds of verbal abuse and not take it to heart. 

https://en.wikipedia.org/wiki/No_such_thing_as_a_stupid_question

"(There's) no such thing as a stupid question" is a popular phrase with a long history. It suggests that the quest for knowledge includes failure, and that just because one person may know less than others they should not be afraid to ask rather than pretend they already know. In many cases multiple people may not know, but are too afraid to ask the "stupid question"; the one who asks the question may in fact be doing a service to those around them.

 

 


   
ReplyQuote
(@chickenhawk)
Member
Joined: 4 years ago
Posts: 44
Topic starter  

@casey

We have questions: From the NRF_server sketch

// Singleton instance of the radio driver

RH_NRF24 nrf24;           Did not work for us. Changed to this as per Pugwash to RH_NRF24 nrf24(8, 53); Now works great. Is this because RH_NRF24 (Radiohead Library) is telling the nrf24 module to use pin 8(ce) and pin 53 (csn)?

Second question: from the Joy stick demo sketch.

// Create an instance of the Radio driver

RH_NRF24 RadioDriver;

Did this part change because we are now sending numerical data?

And next question ( but not the last)

We  know we have to add (   RH_NRF24 nrf24(8, 53);  ) to the Joy stick demo sketch.  But we are unsure of witch way to do it and why.

Add it this way to the existing sketch.

// Singleton instance of the radio driver

RH_NRF nrf24(8, 53);

// Create an instance of the radio driver

RH_NRF24  RadioDriver;

Or

// Create an instance of the radio driver

RH_NRF24 RadioDriver

RH_NRF24 nrf24(8, 53);

In lay man terms if possible would be great


   
ReplyQuote
Page 2 / 3