arduino game controller
In this tutorial, we will learn how to build an Arduino based RC transmitter. Very often, I need wireless control for the projects that I make so. Therefore, I built this multifunctional radio controller, which can be used for pretty much everything. Now I can wireless to control any Arduino project with just some small adjustments at the receiver side. This transmitter can be also used as any commercial RC transmitter for controlling RC toys. Cars, drones and so on. For that purpose, it just needs a simple Arduino receiver, which then generates the appropriate signals for controlling those commercial RC devices. I will explain how everything works in this video through few examples of controlling an Arduino robot car controlling the Arduino and robot from my previous video and controlling a brushless DC motor using an ESC and some servo motors. The radio communication of this controller is based on the inner f24 l1 transceiver module, which, if used in an amplified antenna, it can have a stable range of up to 700 meters in open space. It features 14 channels, six of which are analog inputs and eight digital inputs. It has two joysticks two potentiometers to toggle switches, six buttons and additionally, an internal measuring unit consisting of accelerometer and gyroscope, which can be also used for controlling things with just moving around or tilting the controller. To begin with, let’s take a look at the circuit diagram. The brain of this RC controller is an Arduino Pro Mini, which is powered using two lipo batteries producing around seven point four volts.
We can connect them directly to the roping of the pro mini, which has a voltage regulator that reduces the voltage to 5. Volts. Note that there are two versions of the arduino pro mini like the one i have that operates at 5 volts and the other that operates at 3.3 volts. On the other hand, the ener of 24 lo1 module strictly needs, 3.3 volts and it’s recommended to come from a dedicated source. Therefore, we need to use a 3.3 volts voltage regulator which is connected to the batteries and convert the seven point. Four volts to 3.3 volts. Also, we need to use a decoupling capacitor right next to the module in order to keep the voltage more stable. Does the radio communication will be more stable as well? The NRF 24 L O one module communicates with the Arduino using the SPI library, while the MTU, 6050 accelerometer and rider module uses the I Square C protocol. I actually ended up utilizing all analog and digital pins of the Arduino Pro Mini. So now, if I try to connect everything together using jump wires, it will be quite a mess. Therefore, I designed the custom PCB using the easi da free on line circuit design software. Here i took into consideration the ergonomics of the controller and designed it to be easily held by two hands, while all controls are within the range of the fingers. I made the edges round and added some three millimetres holes, so I can mount the PC bill to something later.
I place the piece for programming the Arduino Pro Mini at the top side of the controller, so they can be easily accessed in case. We want to reprogram the Arduino. We can also notice here that I use the Rx and TX pins of the Arduino for the joystick buttons. However, these two lines needs to be disconnected from anything. While we are uploading the sketch to the Arduino. So, therefore, they are interrupted with two pins, which can be then easily connected using simple jumper caps. Once I finish the design, I generated the Gerber file needed for manufacturing the PCB, then I ordered the PCB from jlc PCB, which are also the sponsor of this video. Here we can simply drag and drop the Gerber file and once uploaded we can review of a PCB in the Gerber viewer. If everything is alright, then we can go on and select the properties that we want for our PCB this time. I chose the PCB color to be black and that’s it. Now we can simply order our PCB at a reasonable price. Note that if it’s your first order from jlc PCB, you can get up to 10 PCBs for only 2, and here it is. I just really love how this PCB turned out in this black color. The quality of the PCB is great, and everything is exactly the same as in the design. Okay, now we can move on with assembling the PCB. I started with soldering the pin headers of the Arduino Pro Mini uneasy and good way to do.
That is to place them on a breadboard, so they can stay firmly in place while soldering. The pro mini also have pins on the sides, but note that these pins locations might vary depending on the manufacturer, for the particular model that I have. I need five pins for each side, while leaving one ground pin empty, because I use its area below on the PCB for running some traces. I soldered the Arduino Pro Mini directly onto the PCB and cut the excess length of the headers right next to it cause the NPU, 6050 accelerometer and gyroscope module. Then I solder the 3.3 volts voltage regulator with a capacitor next to it and another capacitor near the NRF 2411 module. This module have three different versions and we can use any of them here. I continued with the pins for programming the Arduino, the RX and TX pins, the power supply pins and the power switch next for soldering. The petitioners to the PCB I hate to extend their pins using some pin headers we cannote here that I previously cut the length of the knobs, so I can properly fit some caps on them later. However, we will solder the potentiometers to the PCB a bit later. I continued with inserting and soldering the two toggle switches and two joysticks in place. Finally, what’s left now is to solder the four push buttons. However, they don’t have the proper height. So again I used pin headers to extend their pins a little bit and that’s it.
Our PCB is now ready and we can continue with making the cover for it, because I like how this PCB looks and I want it to be visible. I decided to use a transparent and credit for the cover here. I have four millimeters thick, transparent acrylic, which currently have a protective foil and appears to be blue. The idea for the cover is to make two plates with the shape of the PCB and secure one of them at the top side and the other at the bottom side of the PCB. So I mark the PCB shape and using a metal hand. So I cut the acrylic. According to it, then using a simple rasp, I fine tune the shape of the acrylic. The two plates came out great and they perfectly match, with the PCB next time, mark the locations where I need to make openings for the components to pass through using a three millimeter drill. I first made the four holes for securing the plates to the PCB for these holes. I also made counter sinks so that the bolts can be placed flush with the plates for the openings for the toggle switches and the potentiometers. I use six millimeters drill and for the joystick openings I use 25 millimeters Forstner bit again using a rasp. I fine tuned all of the openings before assembling the cover. Just a quick note that I actually soldered the pin headers for the power supply upside down.
So it can be reached from the backside where the battery will be located. Ok, now we can start with assembling the cover. I started with peeling of the protective foil from the acrylic, and, I must admit, was quite satisfying because the acrylic was so clean now. So first I secured the two petitioners on the top plate inserted the three millimeters mounting bolts and placed the 11 millimeters distance rings in place. Then I carefully merged and secured the top plate and the PCB using some bolts. At this point, I finally soldered the petition mirrors to the PCB, because earlier I didn’t know exactly at what height they will be placed next on the back plate. I attached the battery holder using two bolts. I finished the cover assembly by securing the back plate to the back side of the PCB using the four mounting bolts. Finally, we can attach the battery lines to the power supply pins, insert and secure the knobs on the potentiometers, insert the joystick knobs and attach the antenna to the NRF 24 L, o1 module and that’s it. We are finally done with this DIY Arduino RC transmitter. What’S left now is to program the Arduino for programming, a pro mini board. We need an USB to serial UART interface, which can be hooked up to the programming header located on the top side of our controller. Then in the arduino ide tools menu. We need to select the arduino pro or pro mini port, select the proper version of the processor, select the port and select the programming method, 2 USBS, and so now we are able to upload the code to the Arduino.
Let’S, explain how the transmitter code works. So first we need to include the SPI and the RF 24 library for the wireless communication and the icrc library for the accelerometer module. Then we need to define the digital pins, some variables needed for the program below define the radio object and the communication address. Then we need to define a structure where we will store the 14 input values from the controller. The maximum size of this structure can be 32 bytes because that’s, the NRF 24 l1 buffer limit or the amount of data the module can send at once. In the setup section, we need to initialize the MPO 6050 module and we can also calculate the IMU error, which is a value that is later used when calculating the correct angles of the module. You can find more details about this on the website article. There is explanation for each line of the code as well as some dedicated tutorials. Then we need to initialize the radio communication, activate the Arduino internal pull up resistors for all digital inputs and set the initial default values for all variables in the loop section. We start by reading all analog inputs met their values from 0 to 1023 into byte values from 0 to 255, because we already define the variables in our structure as bytes. Each input is stored in a particular data variable from the structure. We should not here that, because we use the pull up, resistors the digital pins readings are 0 when the buttons are pressed.
So, finally, using the radio dot write function, we simply send the values from all 14 channels to the receiver in case the toggle. Each one is switched on, then we used the accelerometer in gyro data instead for the control. Again, you can find more details how we read and calculate this data on the website. So instead of the joystick one x and y values, we are using the angle values. We are getting from the IMU which we previously convert them from values from minus 90 to plus 90 degrees into byte values from 0 to 255, appropriately, so that’s how the transmitter code works. The most important things were: defining the radio communication and sending the data to the receiver. Now, let’s take a look: how we can receive this data here’s a simple receiver code, where we will receive the data and simply print it on the serial monitors, so that we know that the communication works properly again. We need to include the RF 24 library and define the objects and structure the same way as in the transmitter code. In the setup section, when defining the radio communication, we need to use the same settings as the transmitter and set the module as receiver using the radio dot start listening function in the main loop using the available function. We check whether there is an incoming data. If true, we simply read the data and store it into the variables of the structure. Now we can print the data on the serial monitor to check whether the communication works properly, also using the Millis function and an if statement we check whether we keep receiving data or if we don’t receive data for a period longer than 1.
Second, then, we reset the variables to their initial values. We use this method to prevent any unwanted behavior. For example, if a drone has a throttle app and we lose connection, it can keep flying away unless we reset these values so that’s it. Now we can implement this method of receiving the data for any Arduino project, for example here’s the code for controlling the Arduino robot car from one of my previous videos. Here we need to define the libraries the structure in the radio communication, as explained earlier then, in the main loop. We just need to read the incoming data and use any of it for whatever we want. In this case, I use the joystick one values for driving the car. In the exact same way, I may the Arduino intro vote for my previous video to be wirelessly controlled using this RC transmitter. We just need to read the data and, according to it, execute the appropriate functions like moving forward, left, right, byte attack and so on. Lastly, let’s take a look how this transmitter can be used for controlling commercial RC devices, usually for these devices we need to control their servers or brushless motors. So after receiving the data from the transmitter for controlling service, we simply use the Arduino servo library and use values from 0 to 180 degrees for controlling a brushless motor using ESC. We can again use the server library for generating the 50 Hertz PWM signal used for controlling the ESC by varying the duty cycle from 1000 to 2000 microseconds.
We can control the RPM of the motor from zero to maximum. However, more details about controlling brushless motors using ESC in my next video, so that’s it.
arduino game controller Video
arduino game controller news
Posted on Wednesday October 09, 2019Pickaxe Controller Is Great For Minecraft, Just Aim Carefully Hackaday … Continue Reading »
Posted on Wednesday September 18, 2019Arduino, Accelerometer, And TensorFlow Make You A Real-World Street Fighter Hackaday … Continue Reading »
Posted on Saturday September 21, 2019Choose your own price on this giant Arduino eBook training library The Next Web … Continue Reading »
arduino game controller Social
🔬 Now that you’ve gotten your feet wet, dive into the kit and enjoy all nine experiments. Order yours today: http://bit.ly/2MnQ7fr