Cov txheej txheem:

Joystick Sensor: 6 Kauj Ruam
Joystick Sensor: 6 Kauj Ruam

Video: Joystick Sensor: 6 Kauj Ruam

Video: Joystick Sensor: 6 Kauj Ruam
Video: Joystick drift- PS5 - Quick Fix - WD40Contact 2024, Kaum ib hlis
Anonim
Joystick Sensor
Joystick Sensor
Joystick Sensor
Joystick Sensor

Lub joystick sensor tau siv rau ntau hom kev ua haujlwm ntawm cov neeg hlau arduino tab sis nws feem ntau siv rau kev tswj cov vis dis aus game lossis txhua hom kev tswj hwm uas cuam tshuam nrog joystick.

Joystick muaj lub hau yas tshem tau uas koj so koj cov ntiv tes thaum siv. Thaum tshem lub hau no koj muaj qhov pom tau zoo dua ntawm tus pin, lub laub khawm thiab lub ntsuas pa. Analog joysticks yog lub hauv paus muaj zog yog li lawv rov qab qhov txiaj ntsig zoo. Ob lub npog dub nyob rau sab yog lub tsev sensor. Lub sensor ntawm sab laug yog rau nce thiab nqis txav, thaum txav tus pas nce thiab nqis dab tsi uas tau tshwm sim tiag tiag yog tias cov yas sab hauv tau los sib chwv nrog sab sensor paub yog tias tus pas tau txav mus lossis nqis qhov no yog y-axis sensor. Lub sensor nyob ntawm qhov deb tshaj ntawm tus joystick yog hnov qhov txav mus rau sab laug thiab sab xis uas yog x-axis. Cov ntsuas no tau xa cov lus sib piv tab sis tus joystick tseem muaj lub laub khawm lossis hloov pauv, thaum thawb rau ntawm tus joystick qhov hloov pauv sab hauv tau raug thawb xa xa cov digital. Txij li thaum peb paub yuav ua li cas lub joystick sensor ua haujlwm cia peb txuas nws mus rau Arduino thiab saib nws ua haujlwm li cas.

Kauj Ruam 1: Sau Cov Khoom

Sau Cov Khoom
Sau Cov Khoom

-Arduino Ib

-Joystick Sensor

-Female/Txiv neej Jumper Cables

-USB 2.0 Cable Hom A/B.

-Computer

-Arduino IDE

Kauj Ruam 2: Ua Kom Paub Zoo nrog Joystick Pins

Paub Txog Nrog Joystick Pins
Paub Txog Nrog Joystick Pins

Tus joystick muaj tsib tus pin, GND, 5V, VRx. VR thiab SW. Thaum txuas qee yam rau lub zog koj yuav tsum ib txwm muaj qhov tsis zoo thiab qhov zoo uas sib thooj rau qhov tsis zoo thiab sab zoo ntawm koj lub zog. Hauv qhov no tus lej cim npe GND sawv rau "Hauv av" thiab qhov no yog peb tus lej tsis zoo ntawm tus joystick. 5V sawv rau "5 Volts" thiab qhov no yog peb tus pin zoo, ob qho tib si ntawm cov pins no yog peb lub hwj chim txuas. Tom ntej no, VRx yog peb tus kab rov tav lossis x-axis tus pin thiab qhov no yog tus pin analog uas txuas rau sab sib piv ntawm arduino, tib yam nrog VRy tus pin uas yog peb kab ntsug y-axis pins. Ob qho ntawm cov pins no yog tus pin taw qhia yog li thaum lub joystick txav cov pins tab tom tso tawm cov teeb liab analog. Peb tus pin kawg yog SW tus pin uas sawv rau "Hloov" tus pin no txuas nrog lub laub khawm thiab thaum nws raug thawb tus pin tso tawm lub teeb liab.

Kauj Ruam 3: Txuas Txhua Yam Ua Ke

Txuas Txhua Yam Ua Ke!
Txuas Txhua Yam Ua Ke!
Txuas Txhua Yam Ua Ke!
Txuas Txhua Yam Ua Ke!
Txuas Txhua Yam Ua Ke!
Txuas Txhua Yam Ua Ke!
Txuas Txhua Yam Ua Ke!
Txuas Txhua Yam Ua Ke!

Tam sim no nws yog lub sijhawm los ua peb qhov kev sim ua!

Ua ntej tshaj, txuas koj tus poj niam sab ntawm lub jumper cables rau lub joystick pins uas yuav tsum yog tsib nyob rau hauv tag nrho.

Qhov thib ob, txuas tus txiv neej sab ntawm lub jumper cables mus rau tus lej sib xws ntawm koj li arduino. GND rau GND, 5V txog 5V, VRx thiab VRy rau txhua tus pin sib piv ntawm arduino tab sis qhov no peb cov cai qhia peb kom muab cov no rau A0 thiab A1. Tus pin kawg peb xav tau txuas rau lossis arduino yog peb tus pin SW uas yuav mus rau sab digital ntawm arduino yog li ntawd yuav txuas nrog digital pin 2.

Thib peb, txuas koj lub USB cable mus rau arduino thiab nkag rau hauv computer.

Kauj Ruam 4: Sau Txoj Cai

Sau Txoj Cai
Sau Txoj Cai

Tam sim no peb muaj txhua yam txuas nrog peb pawg thawj coj saib arduino nws yog lub sijhawm los rub cov cai kom raug. Brainy Bits muaj cov lej sau lawm rau peb yog li peb tsuas tuaj yeem luam thiab muab lo rau hauv peb Arduino IDE.

Txuas mus rau Code:

1. Qhib daim ntawv arduino IDE tshiab

2. Muab cov cai

3. Ua kom tiav

Kauj Ruam 5: Saib Xyuas Kev Ua

Saib Xyuas Kev Ua
Saib Xyuas Kev Ua

Nyem rau ntawm lub iav tsom iav uas nyob ntawm kaum sab xis saum toj ntawm lub vijtsam. Lub qhov rai tshiab yuav tsum tshwm thiab qhov koj pom yog qhov ua tau thaum txav koj lub joystick. Mus tom ntej thiab txav ncig koj lub joystick thiab x thiab y axis yuav tsum hloov pauv nyob ntawm txoj haujlwm koj joystick nyob ntawm. Sim nias ntawm koj tus joystick thiab koj tus SW tus pin yuav tsum hloov ntawm 1 txog 0. Thaum tus joystick nyob ntawm qhov chaw nruab nrab koj tus x-axis yuav tsum yog ntawm 513 thiab koj y-axis yuav tsum yog ntawm 522. Dab tsi tshwm sim hauv txoj cai yog tias lub voj void yog luam tawm lub joystick txoj haujlwm siv lub teeb liab analog thiab thaum lub pob nyem nrog lub teeb liab.

Pom zoo: