Advice 1: How to connect the joystick to Arduino

There are a variety of ways of conveying information from person to microcontroller or computer, and one of them is the use of a joystick. Let's see how to connect to Arduino analog joystick with two axes and a button.
Joystick with two axes and a button
You will need
  • - Arduino;
  • - two-axis joystick;
  • - 3 resistors of 220 Ohms;
  • - 1 RGB or 3 regular LEDs.
The joystick is easy and convenient to use device for the transmission of information. Types of joysticks in the number of degrees of freedom, the principle of reading and technology, there are many. Joysticks are often used to control the movement of any vehicles driven models of robots. Analog joystick, which we will discuss today is a handle attached to a ball joint with two mutually perpendicular axes. When you tilt the pen, the axis rotates the sliding contact of the potentiometer, thereby changing the voltage at its output. An analog joystick has a clock button which is triggered when the vertical pressure on the handle.
Schematic diagram of the joystick
Connect the joystick via the following diagram. Analog outputs X and Y of the joystick connect to the analog inputs A1 and A2 of the Arduino, the output SW button to digital input 8. The power of the joystick is performed by the voltage of +5 V.
Wiring the joystick to the Arduino
In order to clearly see how the joystick works, let's write a sketch. Declare the pins, let them have modes. Please note, in the procedure setup() we have filed at the input switchPin high level. We've included built-in pull-up resistor on this port. If not included, then when a joystick button is not pressed, the 8th port of the Arduino will hang in the air and catch the pickup. This will entail a chaotic unwanted false alarms.

In the procedure loop() we constantly interrogate the state of the button and display it via the led on output 13. Due to the fact that the entrance switchPin pulled up to the power supply, the led is always on, and when you click off, and not Vice versa.

Next, we read the testimony of the two potentiometers of the joystick output axes X and Y. the Arduino has 10 bit ADC, so the values are taken from the joystick, range from 0 to 1023. In the middle position of the joystick, as seen in the illustration, remove the values in the region of 500 - about the middle of the range.
A sketch to demonstrate the operation of the joystick
Usually a joystick is used to control the motors. But why not use it, for example, to control led brightness? Let's plug in the above scheme RGB led (or three ordinary LEDs) to digital ports 9, 10 and 11 of the Arduino, not forgetting, of course, about the resistors.
Wiring the joystick and RGB LEDs to Arduino
Will change the brightness of the corresponding colors by changing the position of the joystick on the axes, as shown in the figure. Due to the fact that the joystick may not be centered exactly to the manufacturer and have the middle of the scale not at the level of 512, and from 490 to 525, the led may be dimly lit even when the joystick is in the neutral position. If you want to he was completely off, then add the appropriate amendments.
The distribution chart of the brightness of R, G, B channels for the X and Y axes
Focusing on the given diagram, write sketch Arduino control the brightness of the RGB LEDs with the joystick.

First, declare the conformity of pins and two variables - ledOn and prevSw - to work with the button. In the procedure setup() assign pins function and connect to pin button pull-up resistor command digitalWrite(swPin, HIGH).

In the loop loop() define button of the joystick. When you press the button to toggle the modes between "flashlight" mode and "sound to light".

Mode freeMode() to control brightness of LEDs by tilting the joystick in different directions: the greater the tilt axis, the hotter and brighter the color. Moreover, the transformation of values assumed by the function map(value, Otieno, overhage, book reviews, to the upper). The map() function takes the measured values (Otieno, overhage) according to the axes of the joystick in the desired range of brightness (book reviews, to the upper). It is possible to do the same ordinary arithmetic, but this entry is much shorter.

Mode discoMode() three colors alternately gaining brightness and off. To be able to exit the loop when the button is clicked, each iteration check whether the button is pressed.
A sketch to control led brightness using an analog joystick
The result is a flashlight of three-color RGB LEDs, the brightness of each color which is set by using the joystick. And when you click on button you activate the "colour music". Although I have used it, on the contrary, as a nightlight.

Thus, we learned how to connect to Arduino analog two-axis joystick with a button and read his statement. You can come up with and implement a more interesting use of the joystick, than our example.
RGB led, controlled by joystick and Arduino

Advice 2: How to connect to PC joystick Sega

The question of the connection of the joystick SEGA to the computer , and when you run the emulators ROMs sagovsky. To play these games on the keyboard will not work - you will quickly get tired hand.
How to connect to PC joystick Sega
You will need
  • Joysticks, soldering irons, duct tape, LPT socket of type "daddy".(that's the one with pins), a few diodes.
To begin, select a few stray sticks, take necessary tools and spare parts, as well as be enthusiastic.
Next, locate the LPT port on your computer.Outside on the housing of this connector may not be, but if you pay attention to your motherboard, it is unable to detect it.
To the LPT connector on the motherboard connect the appropriate plug. Plug connector LPT buy on one of the radio markets where are sold used spare parts. Perhaps you know a programmer that will share parts.
Next, assemble the schematic and the actual equipment itself. Contacts of the parallel port are used for different purposes. There are transactions that are used for data input, there are those that are designed to display information. Locate the wires in the following colors: yellow clock(CLOCK), orange are used for power, blue - GND, green - latch(LATCH), blue is the control contact.
Transaction Clock and Latch control the transfer of information sequentially. Power to the joystick is supplied through one contact, and is taken from the five wires. Power supply connectors depends on the specific schema of the joystick. The joystick is powered through the diodes. The diodes are the rectifiers, that is, one-way diodes will pass current and the other is not. With LPT port current will pass and is back on his back will not allow the diodes. The direction of the current in the diode is usually depicted as arrows. Solder the diode with the arrow pointing up to the corresponding transactions on the LPT scheme.
Then connect the joystick. Joysticks have the cable Data, which is the Manager and is denoted in blue. Each joystick in this respect is unique and has its own pin datа. Note that the diodes must match the parameters of resistance, is too powerful to not take. DB25M connector has a on old printer cables or modems. Well, if the connector is collapsible.
Having dealt with hardware, install software. To do this, locate the driver, such as PPJoy version 0.83. Install the driver in the usual way, then run Configure Joysticks. In the window that appears, click Add and set the options you want. Takim way, you will add the controller LPT.
Next, add new hardware using the Wizard add hardware". When installing don't forget to select "Install from a list or specified location. Here, specify the folder PPJoy. The system should find the drivers and install them.
Next, install the driver for HID compliant controller. Steps to install driver again, the driver installed with the same folder. All so you install the joystick SEGA to your computer.
Connector plug the LPT needs to be collapsible. If I couldn't find one, cut the cable and ring out the a multimeter.
Useful advice
Sometimes the joystick external connector was not, so the joystick disassemble. Inside the joystick, locate the contacts of the respective colors, connect with plug LPT according to the scheme described above.

Advice 3: How to connect the joystick from the PS3 to my computer

With the joystick from game consoles to play comfortably. In order to connect and sync your d-pad from the PS3, you need to install the program.
How to connect the joystick from the PS3 to my computer
Most modern games, including computer, specially made for joystick control. For example, in a football simulation or racing best played using a gamepad from the box. Can be used for this joystick from a Playstation 3. In that case, if the user connect the controller Dualshock 3 to the PC, then he can get maximum pleasure from almost any game.

The basic steps

In order to play their favorite apps using a gamepad, there is no need to suffer. You only need to connect the controller from the PS3 to the computer using USB cable. Another option of connection involves the use of a Bluetooth adapter. In this case, you can play wirelessly. Of course, you need to connect and sync the Bluetooth adapter with your computer (in the case of using a joystick on a laptop this kind of adapter to buy is not required, since in most models it is already built). After the user connects joystick on the console to the computer, you will need to download and install the program MotionJoy Gamepad Tool. This program you see everything the game, and therefore, synchronization issues of this software, no one will.

How to work with MotionJoy Gamepad Tool?

After the user installs this program, you need to select "Driver Manager". Then download the driver and the computer will think that you are connecting the joystick to consoles. Next, you need to tick on the item "Xbox 360 Controller Emulator" and select your controller in the list. The computer will assume that it is connected to the controller from the XboX. The only drawback is that it will use all the same button labels as the Xbox, but with this you can easily accept and get used to it. Then click the Enable button. Then you can enjoy the games using the joystick from the PS3.

The software MotionJoy Gamepad Tool is ideal to work with a gamepad from the Playstation 3 and Xbox. Its easy to use owners of both consoles, and the startup process sticks to the computer is no different. In the end, the controller from the PS3 will work the same as with the console (vibration and all the other nuances will be present and not going anywhere).
Is the advice useful?