Cov txheej txheem:

Joystick Controlled Servo Siv Arduino (nrog rau Programming): 4 Cov Kauj Ruam
Joystick Controlled Servo Siv Arduino (nrog rau Programming): 4 Cov Kauj Ruam

Video: Joystick Controlled Servo Siv Arduino (nrog rau Programming): 4 Cov Kauj Ruam

Video: Joystick Controlled Servo Siv Arduino (nrog rau Programming): 4 Cov Kauj Ruam
Video: siv servo motors controlled by joystick ver04 2024, Kaum ib hlis
Anonim
Image
Image

Hauv qhov kev qhia no peb yuav ua tus joystick tswj servo siv Arduino Uno. Servo yuav txav mus raws joystick tsab ntawv tsa suab.

Kauj Ruam 1: Cov Cheeb Tsam Yuav Tsum Tau:

Cov Cheeb Tsam Yuav Tsum Tau
Cov Cheeb Tsam Yuav Tsum Tau
  1. Arduino Ib
  2. Joystick
  3. Servo tsav
  4. Cov qhob cij
  5. xov hlau

Kauj Ruam 2: Kev Sib Txuas:

Kev sib txuas
Kev sib txuas

Txuas tag nrho cov khoom siv raws li daim duab kos:

  1. Kev Txuas Joystick:

    1. joystick VCC Arduino 5V
    2. joystick GND Arduino GND
    3. joystick x_axis Arduino tus pin A0
  2. Kev Sib Txuas Servo:

    1. servo VCC Arduino 5V
    2. servo GND Arduino GND
    3. Servo data_pins Arduino tus pin 10

Kauj ruam 3: Programming:

Txoj Haujlwm
Txoj Haujlwm

Tshaj tawm cov haujlwm hauv qab no hauv Arduino Uno board:

#suav nrog kev pabcuam servo;

int x_axis;

koj servo_val;

void teeb tsa ()

{

pinMode (A0, INPUT);

servo.attach (10); cov.

}

void lub voj ()

{

x_axis = analogRead (A0);

servo_val = daim ntawv qhia (x_axis, 0, 1023, 0, 180);

servo.write (servo_val);

}

Kauj ruam 4: Source Code:

code: Source code (nyem qhov no)

Pom zoo: