» Electronics » Arduino »Learning to control servomotors through joysticks using Arduino

Learning to control servomotors through joysticks using Arduino

One of the authors decided to share how you can control two servos using the joystick and controller Arduino. The advantage of such a management is that it is very convenient and understandable, especially for projects with three degrees of freedom. You can read more about how to configure control via the joystick on the Arduino-diy.com website.

Materials and tools:
- microcontroller Arduino (in this homemade applies Arduino Uno Rev 3);
- Two servos from Parallax;
- joystick (also from Parallax);
- circuit board) small);
- connectors for connection;
- A device for tracking the movement of servomotors (a broken webcam and lego cubes are used).

Homemade assembly process:

Step one. We connect servomotors
The homemade assembly process begins with connecting the servomotors. In order to assemble a preliminary layout, a circuit board is used. Then it will be possible to make a separate shield. In the figure you can see how exactly everything is connected.

The red cable is the power, it connects to the 5V pin on the Arduino controller.
The black wire is a minus (ground), it connects to the Arduino output called GND.
The yellow cable from the Right & Left servomotor must be connected to pin 11. On some models, it can be white.
A similar yellow Up & Down cable must be connected to pin 4. It can also be white on some engine models.
It is important to remember that the signal connectors used to control the motor come from the PWM outputs.

Step Two Connect the joystick

How the joystick is connected can be seen in the picture. At first, the scheme may seem rather complicated, but in fact there is nothing complicated here. As with motors, a wiring board is used here.

1. On the joystick module, you can find the outputs U / R + and L / R +. Through these outputs, power is connected. Accordingly, you need to apply + 5V voltage from the corresponding pin to the Arduino.

2. There are also two connectors under the joystick called L / R and two U / D connectors. They need to be connected to the analog outputs A3 and A4.

3. Well, in conclusion, the earth on the joystick must be connected to the earth on the Arduino.

After assembly, the connection must be double-checked. It is because of connection errors that in most cases problems arise. This is especially true when a circuit board is used and there are many connections on it.

Step ThreeSketch for Arduino
The code is very simple and contains detailed comments. The above code just needs to be copied to the Arduino IDE. Once the code is loaded, the engines should not move. They should only start moving when the button on the joystick is pressed.

Problems that may arise and how to solve them
1. If the engines do not turn on, double-check the connection. PWM outputs are used to connect motors, and analog outputs are used to connect joysticks.

2. It happens that immediately after loading the code, the engines begin to vibrate. This happens if you incorrectly connect the pins U / D + L / R +. Connection needs to be checked carefully. In order not to burn the board during the test, it must be disconnected from the computer.

3. If everything is rechecked, but the engines still do not want to work, you can try reconnecting the joystick. It must be removed from the circuit board, and then installed back with some effort. Joystick connectors should go well into the layout.

If everything turned out, now you can start creating any home-made items with control via the joystick. For example, you can make a robot that can be controlled with a joystick, and much more.

upravlenie-servami-johoystikom.rar [906 b] (downloads: 624)
10
10
10

Add a comment

    • smilesmilesxaxaokdontknowyahoonea
      bossscratchfoolyesyes-yesaggressivesecret
      sorrydancedance2dance3pardonhelpdrinks
      stopfriendsgoodgoodgoodwhistleswoontongue
      smokeclappingcraydeclarederisivedon-t_mentiondownload
      heatirefullaugh1mdameetingmoskingnegative
      not_ipopcornpunishreadscarescaressearch
      tauntthank_youthisto_clueumnikacuteagree
      badbeeeblack_eyeblum3blushboastboredom
      censoredpleasantrysecret2threatenvictoryyusun_bespectacled
      shokrespektlolprevedwelcomekrutoyya_za
      ya_dobryihelperne_huliganne_othodifludbanclose
5 comments
The file will be reloaded, it can be downloaded from the article.
Author
the first code seems to be not working, here recently posted a new one. By the way, in the archive the file is empty for some reason.

the sketch is absolutely not working
as if they took a piece out of context
link at the end of the article arduinodzhoystik.rar [96 b] (downloads: 143) - leads to a bunch of pictures and is zero when saving a bookmark (empty file)
tell me what has been done wrong?
Author
it is possible, only it is necessary to change the code ...
Hello. Is it possible to use a button (toggle switch) instead of a joystick so that with each press the servomotors scroll a quarter of a turn?

We advise you to read:

Hand it for the smartphone ...