Notifications
Clear all

Wireless joystick for Arduino car with nRF2401+

39 Posts
3 Users
1 Likes
10 K Views
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

@chickenhawk

All you need is one instance of the RH_NRF24 object:

RH_NRF24 RadioDriver(8, 53);

in both transmitter and receiver sketches.

Forget this

RH_NRF nrf24(8, 53);

It doesn't belong in Bill's joystick code.


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

@pugwash

I will get the grand son to try after school. He is asking for a " Rover 5 robot chassis " for xmas so I know what's coming next. LOL A lot more questions.


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

I notice the Sparkfun inventors kit has a recommended age of 10+

 


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

@pugwash

I will get the grand son to try after school. He is asking for a " Rover 5 robot chassis " for xmas so I know what's coming next. LOL A lot more questions.

With all due respect, I think you will be doing your grandson a disservice by letting him run before he can walk. Buy him a " Rover 5 robot chassis" for Xmas, if you must!

But my advice would be to buy him "C++ for kids", as a stocking filler too.

OK, let him fiddle around with the practical side of building a robot, but ensure that he spends some of his hobby time learning about the basics of programming microcontrollers. If he doesn't learn how C++ works, he will have a great deal of difficulty understanding sketches he downloads from the internet. And if you secretly read the book too, you will no longer be reliant on some "self-appointed expert" (SAE) giving you one-sided advice. This would be a win-win situation.

I still struggle a bit with C++, and I have been programming in other languages for more than 30 years, but knowing how programming logic applies, the transition wasn't too hard. But at 64, I am finding that getting to grasps with some new concepts is difficult.

There have been more than enough adults, let alone children, posting on this forum, that they have envisaged some sort of project that they wish to build, but admit they haven't got a clue how to program an Arduino. I have had to tell some of them that they are in the wrong forum, as the majority of topics discussed here are intermediate level, and there are many good and better resources on the internet for beginners! I am not saying you won't get help here but the forum members, when asked for help generally require precise and not vague information. 

And remember your grandson, at eight years old, has plenty of time left to become competent at this hobby and that instant gratification is not necessarily the best prize to shoot for.

christmas tree

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

@pugwash

Point taken, with thanks.

The robot is just a side line. He has been slowly working through the " Sparkfun Inventor's Kit" it was when he got to " Project 5: Robot " that he kind of got side tracked. When he was doing some research ( on line ) he came across a video of the wireless car, and away things went.  But it was a good learning lesson for him, walk before you can run.  But it had it a good side, now he is back at the inventor's kit. I think the hardest parts is learning the " language " if that is the right word.  He went and bought with his own money a " Arduino for Dummies " book.  ( I wish he would work that hard on his school work) His goal is to build a ROV with a camera and a gripper arm.  If all of this keeps him moving towards his goal the it has been time well sent.

I again I thank you and everyone else for for time and help


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

@pugwash

He is back to working through the Sparkfun book. But we do have a question.

he has being going line by line through the nrf24l01+ joystick for robot car sketch and seams to have a good grip what each line of code says and does.  All but 2 lines of code that he is struggling with.

// Declare unsigned 8-bit motorcontrol array

// 2 Bytes for motor speeds plus 1 byte for direction control

uint8_t  motorcontrol(3);

// Define the Message Buffer

uint8_t buf(RH_NRF24_MAX_MESSAGE_LEN);

Question why a 8-bit motorcontrol array? 1 byte (8 bit) for forward-1 byte (8 bit) for backwards and 1 byte (8 bit) for direction control -- hence " motorcontrol(3)" ?   Next if later you wanted to add a second joystick would you go to a 16-bit motorcontrol array, or a third joystick to a 24-bit motorcontrol array?

 


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

@chickenhawk

Question why a 8-bit motorcontrol array? 1 byte (8 bit) for forward-1 byte (8 bit) for backwards and 1 byte (8 bit) for direction control -- hence " motorcontrol(3)" ?   Next if later you wanted to add a second joystick would you go to a 16-bit motorcontrol array, or a third joystick to a 24-bit motorcontrol array?

No, you would create three arrays!

uint8_t  motorcontrol1[3];

uint8_t  motorcontrol2[3];

uint8_t  motorcontrol3[3];

Think of the extra two joysticks as instances of the first joystick and each needs its own control array!

Hope that helps ? 

Edited: I had to edit those parentheses to square brackets before some clever clogs jumps on me about it!


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

@chickenhawk

I forgot to answer the first part of your question. The programmer has made his life easier by passing 3 values as an array through the nrf24lo1. Each byte can have a value between 0 and 255, this is conveniently the was to control PWM (pulse width modulation) pins for the speed control, these make use of two bytes and a third byte is an absolute number representing forward and another absolute number representing reverse. It has been done like this because unlike Python's list type, you can't mix data types in an array in C++!


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

@chickenhawk

Question why a 8-bit motorcontrol array? 1 byte (8 bit) for forward-1 byte (8 bit) for backwards and 1 byte (8 bit) for direction control -- hence " motorcontrol(3)" ?   Next if later you wanted to add a second joystick would you go to a 16-bit motorcontrol array, or a third joystick to a 24-bit motorcontrol array?

No, you would create three arrays!

uint8_t  motorcontrol1[3];

uint8_t  motorcontrol2[3];

uint8_t  motorcontrol3[3];

Think of the extra two joysticks as instances of the first joystick and each needs its own control array!

Hope that helps ? 

Edited: I had to edit those parentheses to square brackets before some clever clogs jumps on me about it!

That was my poor eye sight , seeing ( ) instead of [ ]

I think I need the Readers Digest large print.  We have run into that before using the wrong set of ( ) or [ ] we sent hours trying to figure out what we did wrong only to have it jump right out at us.


   
ReplyQuote
Page 3 / 3