Cov txheej txheem:

Arduino Tsuav Tower Game: 8 Kauj Ruam
Arduino Tsuav Tower Game: 8 Kauj Ruam

Video: Arduino Tsuav Tower Game: 8 Kauj Ruam

Video: Arduino Tsuav Tower Game: 8 Kauj Ruam
Video: There You Are 2024, Hlis ntuj nqeg
Anonim
Arduino Tsuav Tower Game
Arduino Tsuav Tower Game

Hauv cov lus qhia no kuv yuav qhia koj yuav ua li cas tsim lub tsuav ntauwd game nrog arduino, tsib servo's thiab qee qhov ntsuas.

Lub hom phiaj ntawm qhov kev ua si yog yooj yim, ob tus neeg pov lub tsuav rau saum thiab koj tig rov nias lub pob, lossis txwv tsis pub siv lub ntsuas. Thaum koj ua tus servo txav lub platform ntawm ob sab ntawm lub thawv ua cov tsuav poob qis. Thawj qhov tau txais nws cov tsuav tawm ntawm tus yees yeej nrog cov nyiaj tau los ntawm qhov pom nws/nws dov.

Txoj haujlwm no tuaj yeem hloov kho lossis nthuav dav kom siv lwm yam kev lom zem los yog loj dua lossis me dua.

Kauj ruam 1: Yuav tsum tau ua

Yuav tsum muaj
Yuav tsum muaj

Rau qhov haujlwm no koj yuav xav tau:

Electronics:

- Ib qho AC/DC Adapter (5V, 2.1A, Chaw Zoo)

- Ib Arduino Uno

- USB-B cable

- 32x txiv neej jumper hlau

- 5 x servo

- 5x 10k resistors

- 3x Push Button

- Lub Hwj Chim Ruaj Ntseg Resistor

- Lub teeb Sensor

Cov Khoom Siv Hauv Tsev:

- MDF phaj lossis lwm yam ntoo

- ntoo kua nplaum

- ntoo skewers

- ntawv yas

TSEEM CEEB: Cov adapter yuav tsum yog 5 volt vim tias qhov no yog qhov hluav taws xob ntawm cov servos thiab ntau dua yuav ua rau lawv tawg. Kuj xyuas lub adapter yog qhov nruab nrab zoo thiab muaj ntau dua lossis 2A txhawm rau ua kom muaj zog txhua qhov kev pabcuam.

Kauj ruam 2: Lub zog

Fais fab
Fais fab
Fais fab
Fais fab
Fais fab
Fais fab
Fais fab
Fais fab

Rau txhua qhov kev pabcuam ua haujlwm koj yuav xav tau lub zog ntau dua li cov arduino tuaj yeem muab tau. Nov yog qhov adapter yog rau. Tus adapter yog 5V uas yog qhov ua haujlwm voltage ntawm servos nrog rau txhua lub ntsuas ntsuas kom qhov ntawd yuav zoo meej. Ntxiv mus nws muab 2.1A uas txaus rau txhua qhov kev pabcuam ib zaug. Yog li ua ntej tshaj plaws koj yuav txiav cov hlau ntawm koj lub adapter thiab tawv nws. Yog tias koj yuav tsum cais cov xov hlau ib ntawm lawv yog 5V thiab lwm qhov yog hauv av. Yog tias koj muaj ib txoj hlua tuab uas txhais tau tias ob lub xov hlau nyob ntawd thiab koj yuav tsum cais lawv. Koj tuaj yeem siv lub ntsuas ntsuas kom pom cov xov tooj twg yog 5V. Yog tias koj tso koj qhov kev sojntsuam rau ntawm cov xov hlau thiab nws nyeem 5V cov xov hlau ntawm qhov kev sojntsuam liab yog 5V thiab ib qho ntawm cov sojntsuam dub yog hauv av. yog tias nws nyeem -5 volt nws txhais tau tias koj muaj lawv qhov tsis raug ib puag ncig. Tam sim no koj tuaj yeem qhwv cov xov nyob ib puag ncig ob qho tib si thiab muab tso rau hauv koj lub rooj noj mov, 5v hauv + thiab hauv av rau hauv -. Tam sim no muaj ib qho kawg uas yuav tsum tau siv xov hlau los ntawm koj li arduino av mus rau - ib yam yog li ntawd lub adapter thiab arduino muaj ib qho hauv av ib txwm yog li nws yuav tsis ua haujlwm.

Kauj ruam 3: Servos

Servos
Servos
Servos
Servos

Tom ntej no peb yuav xaim peb cov servos. Tam sim no txhua qhov kev pabcuam muaj peb lub xov tooj daj, ib lub txiv kab ntxwv thiab xim av.

- Yellow to (PWM) pin 4, 5, 6, 9, 10, 11

- Txiv kab ntxwv rau lub zog

- Xim av rau hauv av

Tab sis koj tsis tuaj yeem tsuas yog txuas lawv rau ib tus pin, nws tseem ceeb heev uas yuav tsum tau siv PWM tus pin. Thaum feem ntau cov pins tuaj yeem tsuas yog nyob lossis tawm ntawm PWM pins tseem tuaj yeem xa qhov tseem ceeb ntawm qhov uas peb xav tau los muab cov servo rau txhua txoj haujlwm uas peb xav tau.

Kauj ruam 4: Laub Khawm

Laub Khawm
Laub Khawm
Laub Khawm
Laub Khawm

Tom ntej no peb tab tom yuav xaim peb lub laub khawm kom tswj tau servos 1, 2 thiab 4.

- Txuas lub laub khawm rau lub khob cij

- Los ntawm txoj cai khawm ceg mus rau lub zog.

- Los ntawm sab laug khawm ceg mus rau tus pin 3

- Los ntawm sab laug khawm ceg mus rau 10k resistor

- Los ntawm 10k resistor rau hauv av

Tam sim no rov ua qhov no rau tag nrho peb lub khawm.

Kauj Ruam 5: Quab Yeem Yooj Yim Resistor

Quab yuam rhiab rhiab heev
Quab yuam rhiab rhiab heev

Tom ntej no yog lub zog rhiab resistor uas ntsuas lub zog. Tam sim no rau lub ntsuas no peb tab tom yuav siv cov pins sib piv vim tias cov pins sib piv ua haujlwm nrog qhov tseem ceeb ntawm 0 thiab 1023 hloov qhov tsuas yog qhib lossis tawm uas tsim nyog rau lub zog ntsuas.

- Txuas lub zog rhiab rhiab rau lub rooj tsavxwm

- Sab laug tus pin rau lub zog

- Txoj cai tus pin rau analog pin A0

- Txoj cai tus pin rau 10k resistor

- 10k resistor rau hauv av

Kauj Ruam 6: Lub Teeb Sensor

Lub teeb Sensor
Lub teeb Sensor

Thiab thaum kawg peb tab tom ntxiv lub teeb pom kev zoo. Xyuas kom tus pin ntev nyob ntawm sab laug.

- Txuas lub teeb pom kev zoo mus rau lub khob cij

- Sab laug ceg rau lub zog

Txoj cai ceg rau analog pin A1

Txoj cai sab xis rau 10k resistor

- 10k resistor rau hauv av

Kauj ruam 7: Casing

Casing
Casing
Casing
Casing
Casing
Casing

Raws li tus qauv ntawm thawj daim duab koj tuaj yeem pom cov phiaj. Tom qab ntawd ua cov qhov qhia nyob rau sab xub ntiag thiab tom qab. Tom qab ntawd koj tuaj yeem lo txhua yam ua ke kom zoo li cov duab 2 thiab 3. Tsuas yog tsis txhob lo rau lub platform servo rau servos tsuas yog siv tus qauv servo ntu thiab ntsia hlau rau qhov ntawd. Tom qab ntawd muab cov kua nplaum tso rau ntawm nws thiab lo lawv hla lub qhov. Tom qab ntawd ntawm lwm sab muab lwm lub platform zoo ib yam kom koj muaj ob lub platform ntawm ib qho kev pabcuam. Yog li pom qhov no hais txog daim duab plaub thiab thib tsib.

Tau kawg koj tuaj yeem sib txawv qhov loj ntawm lub npov nrog rau cov swb ntawm sab hauv yooj yim heev.

Kauj ruam 8: Code

Nov yog txoj cai tswj hwm txhua tsib servos siv lub ntsuas.

button1 = servo1

button2 = servo2

lub teeb sensor = servo3

khawm 3 = servo4

quab yuam rhiab resistor = servo5

Pom zoo: