Hey guys! As I'm sure you know by now, I'm a huge fan of the NRF24L01, it's a great way to get two Arduinos talking. When the RF Nano (Arduino Nano with integrated NRF24L01) came on the scene about a year ago, I was so excited. It had never been so easy for me and my students to build custom controllers for our robotics projects! Since then, I've been using our trusty RF Nano controller PCB. The same one we've had in the shop! It has been a trusty little board, but now it's time for an upgrade! As always, if you'd like to watch the video for this tutorial we have it right here. Enjoy!
For those of you reading along, here's our original RF Nano controller.
And here is our new upgrade!
Aside from the new board shape, we've added two large pushbuttons to the left of the controller, a power switch in the lower left-hand side of the controller, two right-angle shoulder buttons, a surface-mount 18650 battery holder around back, and a black acrylic protection plate!
We've got two main goals with this tutorial here. The first is to share some really fun code examples and share some of the background info for anyone who has purchased our RF Nano controller in our shop. The second is to provide the files, and the guidance you'd need to build your very own custom controller! Whether you bought a controller from us, or are trying to build your own, the first step is taking a closer look at our schematic!
Part One: The Schematic
One of the coolest things about the RF Nano is that because the radio IC is integrated into the Arduino Nano itself, the schematic and project as a whole can remain much more simple, and clean. In this example, I'm using EasyEDA to create this schematic. I love using EasyEDA, it's free, feature-rich, and a perfect way to make custom circuit boards. Let's take a look at our schematic.
Right and Left Bumpers:
These guys are wired up to pins D6 and D7 on our Arduino, with the other side of our buttons tied to GND. We'll be using the Arduino's internal pull-up resistor so that's all we'll need in terms of circuitry to read our button data!
A and B Buttons:
We'll have our larger black push buttons wired up to pins D4 and D5
Right and Left Joysticks:
As with all joysticks and potentiometers, we need 5v headed into our joysticks and GND heading out, with the voltage change pin wired up to pins A0 and A1. The pushbuttons inside of our joysticks are wired up just like our other buttons, with one side wired up to a digital pin, and the other side tied to GND. The pins we use for the pushbuttons are pins D2 and D3!
The accelerometer/gyroscope module we're using is the MPU-6050, it's a great little board! And since it's an i2c device, we only need 4 pins total to get it working! 5v goes in, GND goes out, and we have our SDA and SCL pins. On a standard Arduino Uno and Nano, the i2c bus is hardwired into pins A4 and A5, with A4 for SDA and A5 for SCL.
Part Two: The PCB
Now, one of our biggest goals here is to create an awesome new PCB shape that will take our controller project to the next level! There are more than a few ways to pull this next part off, but I've found that one of the easiest is to use your favorite CAD program to create a .DXF file for your circuit board outline. What's cool about using this method is that we'll be able to use that same .DXF to cut out our acrylic backplate! Now for this example, I'm using Fusion 360, but there are all kinds of ways to create your controller PCB shape, if you'd like you can download the .DXF for this project right here.
In Fusion 360, this is simply a matter of creating a new "sketch", and using the arc, line, circle, and curve tool to create your one custom shape! Feel free to watch our video to see this part in action. In this example, I started with an "arc" then used the line tool and the "conic curve" tool to make the first half of my controller PCB outline.
What I usually like to do is create half of my controller first, we'll then duplicate and rotate it around! That way we know that both halves are perfectly symmetrical!
This part seemed a little strange to me, instead of a "copy" or "duplicate" tool, the easiest way to copy this half of the sketch is with the move tool. Highlight your sketch, and press"M" on your keyboard.
Be sure that you have the "Create Copy" option selected. Once that's all set, all you'll need to do is move over your newly created half, rotate, and line it up with the other half of your controller! Once you have that taken care of, all you'll need to do it click on finish sketch, then save your sketch as a .DXF. I would recommend saving the file somewhere simple, like the desktop, we'll use your newly created file in the next step!
Once you have your circuit board outline made it's time to head back over to EasyEDA to convert our schematic into a PCB! Open up your schematic from before, and make sure you have all of the connections you'd like all figured out. If you'd like to customize our design, be sure you make all of the changes you'd like before this next step. Once you're satisfied and ready to move on, you'll want to save your schematic and then click the "convert to PCB" button at the top of your screen.
In a new tab, you should see all of your components, just as you'd seem them with a regular square-shaped PCB. At this point, you'll want to highlight the purple square (your PCB outline) and delete it!
Next, we need to import our newly created .DXF and assign it as our new PCB outline! You'll want to head to over to the file tab up top, and select "import", then ".DXF" just as we see here in the picture below.
Once you've selected .DXF, then you'll see the following menu, be sure that you're applying the newly imported .DXF as the board outline. Your menu items should look just like mine. If everything looks good, go ahead and select "import"!