Cov txheej txheem:

Arduino LCD Game: 3 Kauj Ruam (nrog Duab)
Arduino LCD Game: 3 Kauj Ruam (nrog Duab)

Video: Arduino LCD Game: 3 Kauj Ruam (nrog Duab)

Video: Arduino LCD Game: 3 Kauj Ruam (nrog Duab)
Video: 4 Amazing Arduino Games - DIY Game Console 2024, Kaum ib hlis
Anonim
Image
Image
Sib dhos Cov Khoom
Sib dhos Cov Khoom

Ua ntau yam zoo yog qhov yooj yim heev nrog Arduino microcontrollers. Cov lus qhia no qhia koj yuav tsim qhov yooj yim 1-khawm cov vis dis aus game ua los ntawm cov tes me me thiab Tinkercad Circuits. Nws yog kev ua si sab-scrolling dhia. Qhov no ua haujlwm raws li qhov pib zoo rau tsim koj tus kheej kev ua si los ntawm cov khoom siv hluav taws xob yooj yim.

Daim ntawv teev npe:

  • 1 x Arduino UNO
  • 1 x LCD npo (16 x 2 cim)
  • 1 x Electronics breadboard
  • 1 x 220 Ω resistor
  • 1 x Pushbutton hloov
  • Solid-core hookup hlau
  • 1 x USB cable

Kauj Ruam 1: Sib dhos Cov Khoom

Sib dhos Cov Khoom
Sib dhos Cov Khoom

Qhov xav tau yog qhia hauv daim duab saum toj no. Pib nrog Arduino tsis muaj zog. Tsis txhob ntsaws rau hauv USB cable. Qhov ntawd yuav tshwm sim hauv qib tom ntej thaum nws txog sijhawm rau program nws thiab sim ua si tawm.

Siv txoj hlua txuas ntev los txuas 5V teeb liab ntawm Arduino mus rau sab laug deb ntawm kab liab nyob rau sab saum toj ntawm lub khob cij.

Siv txoj hlua txuas ntev los txuas GND lub teeb liab mus rau sab laug ntawm cov dub (lossis xiav ntawm qee lub rooj noj mov) ua kab saum toj kawg ntawm lub khob cij.

LCD (Cov Khoom Siv Crystal Display) muaj 16-tus pin txiv neej lub taub hau nyob hauv qab. Txuas qhov no rau hauv daim ntawv qhia zaub mov raws li qhia hauv daim duab. Txhua yam ntawm cov cim hluav taws xob uas ua kom lub zog thiab tswj lub LCD dhau los ntawm kab ntawv no.

Cov pins no (ntawm sab laug mus rau sab xis):

  1. GND - lub zog hauv av teeb liab
  2. VCC - teeb liab lub zog zoo
  3. V0 - sib piv kho
  4. RS - sau npe xaiv
  5. R/W - nyeem/sau xaiv
  6. E - kev pabcuam ua haujlwm teeb liab
  7. DB0 - cov ntaub ntawv me 0 (tsis siv ntawm no)
  8. DB1 - cov ntaub ntawv me ntsis 1 (tsis siv ntawm no)
  9. DB2 - cov ntaub ntawv me ntsis 2 (tsis siv ntawm no)
  10. DB3 - cov ntaub ntawv me ntsis 3 (tsis siv ntawm no)
  11. DB4 - cov ntaub ntawv ntsis 4
  12. DB5 - cov ntaub ntawv me ntsis 5
  13. DB6 - cov ntaub ntawv me ntsis 6
  14. DB7 - cov ntaub ntawv me ntsis 7
  15. LED+ - backlight LED zoo
  16. LED- - backlight LED tsis zoo

Siv cov xov hlau txuas luv, txuas GND thiab LED- (tus pin 1 thiab 16) rau kab dub nyob saum toj.

Ib yam li ntawd, txuas VCC (tus pin 2) mus rau kab liab nyob rau sab saum toj nrog txoj hlua txuas luv.

Khoov cov hlau ua ntawm 220 Ω tus tiv thaiv (liab-liab-xim av xim bands) thiab txuas nws ntawm LED+ thiab kab liab nyob rau sab saum toj ntawm lub khob cij.

Siv cov xov txuas ntev dua los ua qhov seem ntawm kev sib txuas:

  • Txuas DB7 rau Arduino tus pin 3
  • Txuas DB6 rau Arduino tus pin 4
  • Txuas DB5 rau Arduino tus pin 5
  • Txuas DB4 rau Arduino tus pin 6
  • Txuas E rau Arduino tus pin 9
  • Txuas R/W rau Arduino tus pin 10 (lossis rau kab dub nyob saum lub khob cij)
  • Txuas RS rau Arduino tus pin 11
  • Txuas V0 rau Arduino tus pin 12 (lossis rau kab dub nyob saum lub khob cij)

Ntsaws lub laub khawm qhov twg mus rau sab laug ntawm lub vijtsam LCD, straddling cov channel khiav raws nruab nrab ntawm lub khob cij (saib daim duab saum toj no). Txuas ib qho ntawm ob sab saum toj ntawm lub khawm mus rau kab dub nyob rau sab saum toj ntawm lub khob cij siv lub xov tooj sib txuas luv. Txuas lwm tus pin nyob rau sab saum toj ntawm lub pob kom tus pin 2 ntawm Arduino.

Kauj ruam 2: Programming Arduino

Programming Arduino
Programming Arduino

Txij ntawm no mus, koj yuav tsum tau npaj rau program Arduino thiab sim nws tawm.

Pib los ntawm kev ua kom ntseeg tau tias koj muaj Arduino software teeb tsa hauv koj lub computer. Rub tawm LCD_Game.ino cov ntaub ntawv ntawm nplooj ntawv no rau koj lub khoos phis tawj thiab qhib nws hauv Arduino software. Xyuas kom lub rooj tsavxwm tau teeb tsa kom raug rau lub cajmeem (Cuab Yeej → Pawg → Arduino Uno).

Txuas Arduino rau koj lub computer siv USB cable. Qhov no yuav muab lub zog rau Arduino/game thiab tso cai rau koj rub koj cov ntawv mus rau Arduino.

Txij ntawm no mus, lub vijtsam ntawm lub vijtsam LCD yuav tsum ci.

Program Arduino los ntawm kev xaiv File → Upload (lossis nias lub khawm sab xis saum toj ntawm Arduino software).

Yog tias txhua yam mus tau zoo, lub vijtsam LCD yuav tsum tam sim no qhia pom qhov pib game zoo li hauv daim duab saum toj no.

Kauj Ruam 3: Hloov Yam thiab Ua Arduino Game Shield

Hloov Yam thiab Ua Arduino Game Shield
Hloov Yam thiab Ua Arduino Game Shield

Txij ntawm no koj muaj txhua yam ua haujlwm, yog li yuav muaj dab tsi ntxiv?

Yog tias koj xav hloov txoj kev ua haujlwm ntawm kev ua si, lossis ua kom txias txias luam tawm pawg thawj coj saib rau txoj haujlwm no uas txuas ncaj qha mus rau Arduino thiab hloov tag nrho cov xov tsis zoo, ntawm no yog yuav pib li cas.

Kuv tsim qhov kev ua si nkaus siv qhov txias heev (DAWB!) Online hluav taws xob simulator Tinkercad Circuits. Kuv tau muaj qhov kev ua si tag nrho ua haujlwm thiab sim ua ntej puas tau siv Arduino tawm ntawm cov khoom siv. Nov yog lub voj voog virtual rau Arduino LCD game.

Koj tuaj yeem ua qhov kev ua si raug cai hauv koj tus browser yam tsis tau muab tso ua ke ib qho khoom siv hluav taws xob tiag tiag ("Auj, tam sim no koj qhia kuv"). Yog tias koj xav hloov pauv qhov kev ua si, lossis tshawb xyuas seb muaj dab tsi tshwm sim, koj tuaj yeem luam theej tawm lub voj voog virtual uas siv "Duplicate Project" khawm. Tom qab ntawd koj tuaj yeem hloov kho qhov chaws thiab sim hloov pauv nyob ntawd. Kuj tseem muaj qhov tshwj xeeb debugger qhov twg koj tuaj yeem hla dhau txoj haujlwm ib-kab-kab thiab pom dab tsi tshwm sim!

Yog tias koj xav tau ntau, koj tseem tuaj yeem ua lub rooj tsav xwm hauv Circuit kom txuas koj cov khoom siv hluav taws xob zoo rau Arduino. Txoj haujlwm muaj "Download Gerber" khawm uas yuav tau txais koj cov ntaub ntawv tsim nyog muab rau lub chaw tsim khoom luam tawm Circuit Board (PCB) kom muaj kev cai luam tawm Circuit board ua. Nov yog qee cov ntaub ntawv muaj txiaj ntsig ntawm kev tau txais PCB ua.

Txaus siab rau!

Pom zoo: