The nRF24L01 - Wire...
 
Notifications
Clear all

The nRF24L01 - Wireless Joystick for Arduino Robot Car with nRF24L01+  

Page 2 / 2

Scott
(@scott)
Active Member
Joined: 2 months ago
Posts: 11
 

@rich1860

Thanks, I have found the library but not the youtuber you referred to, do you have a link?


ReplyQuote
Troles
(@troles)
Active Member
Joined: 3 months ago
Posts: 8
 
Posted by: @scott

@rich1860

Thanks, I have found the library but not the youtuber you referred to, do you have a link?

I found the youtube video that he suggested, it is :

he gives the code, you have to download it in a .RAR  file (which is a type of zip that i had not used but could open it in winzip, and when unzipped it has code for car adn transmitter, as well as 2 fritz schematics).  I have not tried it yet, but plan to in the next few days.  hoping it helps with the delay issue...  I have tried a few others but have not been happy.  Ultimately I want to get something that responds well with the remote, and then modify the code to get a better response from trying to go "diaganally".  these codes seem to be good for forward, back, turn right, turn left.  But the turn always seems to be more of a twist, and less of a diagonal/vector/curving while moving forward turn when joystick is pushed (for example) to the 2oclock position.  Anyway, all that should be able to be adjusted in the code and the pwm strength and formula.  I just haven't put much time into it because I haven't gotten the nrf24l01 to work well.  (I may even bail on the nrf and go to bluetooth for now, but i am sure that will open up a new can of worms.).  I am still pretty new at all this, but I love it, just wish I had more time to play with it all.  I will post my journey if i find things that can be helpful to others (particularly novices like me).  


ReplyQuote
Rich1860
(@rich1860)
Active Member
Joined: 3 months ago
Posts: 14
 

Thanks for posting the Tube link. I liked this link because it was already written for a four wheel robot. The time delay seems to me is because of the reliable code used in RadioHead. That may be an overkill in a robot since speed is a big factor when controlling the device. Look at the library in RadioHead, it may be possible to convert the reliable code to "one transmission" code, which should go faster. My code probably could be improved, but it is good enough for the students to build their own robot. I would rather see them get into the code and figure out how to make it work better if they want to. And BTW, I am really a novice at the programming, as I mentor the students on building FIRST robots, but others mentor on programming.


ReplyQuote
Scott
(@scott)
Active Member
Joined: 2 months ago
Posts: 11
 

Thanks Troles, I think that like you, I'm having trouble with the reliability of Nrf24-01's and perhaps should consider Bluetooth. These modules don't seem to be all that popular in arduino projects and there's probably a reason for that. Still on the lookout for any code like this which drives a servo if anyone sees one. Thanks again.


ReplyQuote
Arlo
 Arlo
(@arlo)
Active Member
Joined: 1 week ago
Posts: 9
 

@scott

Hi Scott,

       I ran across this searching for adding servos for a pan and tilt to a camera mounted to an Elegoo smart robot 3.0. It  seems you can make the Radiohead library use Timer 2 instead of trying to make the servo library use it. I had to open up the Radiohead library then open the RH_ASK.ccp file. Scroll down about 25 lines to #define RH_ASK_ARDUINO_USE_TIMER2

and uncomment it.

Hope this helps

        Arlo

 


ReplyQuote
Scott
(@scott)
Active Member
Joined: 2 months ago
Posts: 11
 

@arlo

Well done Arlo, I'd never have worked that out myself. I'll give it a try. 


ReplyQuote
Scott
(@scott)
Active Member
Joined: 2 months ago
Posts: 11
 

Oh dear. I went to "RH_ASK.ccp" and found this block, and uncommented the bottom line to read as below:

// RH_ASK on Arduino uses Timer 1 to generate interrupts 8 times per bit interval
// Define RH_ASK_ARDUINO_USE_TIMER2 if you want to use Timer 2 instead of Timer 1 on Arduino
// You may need this to work around other librraies that insist on using timer 1
// Should be moved to header file
define RH_ASK_ARDUINO_USE_TIMER2

Ran the program and got this error:

A:\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp:34:1: error: 'define' does not name a type; did you mean 'rewind'?
define RH_ASK_ARDUINO_USE_TIMER2
^~~~~~
rewind
A:\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp: In member function 'virtual bool RH_ASK::init()':
A:\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp:72:5: error: 'thisASKDriver' was not declared in this scope
thisASKDriver = this;
^~~~~~~~~~~~~
A:\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp: In function 'void __vector_11()':
A:\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp:716:5: error: 'thisASKDriver' was not declared in this scope
thisASKDriver->handleTimerInterrupt();

Does anyone know what I did?

This post was modified 1 week ago 2 times by Scott

ReplyQuote
Arlo
 Arlo
(@arlo)
Active Member
Joined: 1 week ago
Posts: 9
 

@scott

Scott, are you still trying to use Servo. Timer2 library. It might be causing a reverse conflict with servo and radiohead both trying to use timer 2 now. I didn't have to use it at all to get Bill's code and servo library to play nice together.


ReplyQuote
Scott
(@scott)
Active Member
Joined: 2 months ago
Posts: 11
 

@arlo,

No, I've now removed that from the library and reinstalled arduino IDE to be safe. I did an experiment to see what happened if I commented out "define RH_ASK_ARDUINO_USE_TIMER2" and got this:

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':
(.text+0x0): multiple definition of `__vector_11'
libraries\RadioHead\RH_ASK.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Uno.

 

I uncommented it again and got this back:

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

A:\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp:34:1: error: 'define' does not name a type; did you mean 'rewind'?
define RH_ASK_ARDUINO_USE_TIMER2
^~~~~~
rewind
A:\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp: In member function 'virtual bool RH_ASK::init()':
A:\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp:72:5: error: 'thisASKDriver' was not declared in this scope
thisASKDriver = this;
^~~~~~~~~~~~~
A:\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp: In function 'void __vector_11()':
A:\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp:716:5: error: 'thisASKDriver' was not declared in this scope
thisASKDriver->handleTimerInterrupt();
^~~~~~~~~~~~~
exit status 1
Error compiling for board Arduino Uno.

It also throws the above error with Bill's original "nRF24L01+ Joystick Receiver for Robot Car" code, which has no servo libraries enabled.

 

Thanks for your time on this. 

 


ReplyQuote
Scott
(@scott)
Active Member
Joined: 2 months ago
Posts: 11
 

Scratch that, I didn't put in the # you said at the beginning of:

#define RH_ASK_ARDUINO_USE_TIMER2

 

I'll carry on and see how I go.

Thanks again.

 

 


ReplyQuote
Scott
(@scott)
Active Member
Joined: 2 months ago
Posts: 11
 

@arlo

Mate, you sussed it, thanks so much. It's been weeks and I thought I was going to have to give up.

Scott.


ReplyQuote
Arlo
 Arlo
(@arlo)
Active Member
Joined: 1 week ago
Posts: 9
 

@scott Hopefully you will not run into the same thing I did. I could get the servo sketch to work or Bill's to work but not at the same time, through trial and error (heavy on the error part) I finally was able to modify Bill's a little to make it work with two joysticks, one for the car and one for the pan and tilt. If you run into this roadblock let me know and I will post the code so you can see what I did.

                               Arlo


ReplyQuote
Page 2 / 2