Cov txheej txheem:

Kuaj Bare Arduino, Nrog Game Software Siv Capacitive Input & LED: 4 Cov Kauj Ruam
Kuaj Bare Arduino, Nrog Game Software Siv Capacitive Input & LED: 4 Cov Kauj Ruam

Video: Kuaj Bare Arduino, Nrog Game Software Siv Capacitive Input & LED: 4 Cov Kauj Ruam

Video: Kuaj Bare Arduino, Nrog Game Software Siv Capacitive Input & LED: 4 Cov Kauj Ruam
Video: #SanTenChan читает гнома из второй серии книги Сани Джезуальди Нино Фрассики! 2024, Kaum ib hlis
Anonim
Kuaj Bare Arduino, Nrog Game Software Siv Capacitive Input & LED
Kuaj Bare Arduino, Nrog Game Software Siv Capacitive Input & LED
Kuaj Bare Arduino, Nrog Game Software Siv Capacitive Input & LED
Kuaj Bare Arduino, Nrog Game Software Siv Capacitive Input & LED

"Push-It" Sib tham sib game siv daim npav Arduino liab qab, tsis muaj cov khoom sab nraud lossis cov hlua xav tau (siv lub peev xwm 'kov' cov tswv yim). Qhia saum toj no, qhia tias nws khiav ntawm ob lub rooj sib txawv.

Push-It muaj ob lub hom phiaj.

  1. Txhawm rau ua pov thawj/txheeb xyuas sai sai tias koj lub Rooj Tswjhwm Saib Arduino ua haujlwm thiab koj tau teeb tsa kom raug txhawm rau rub tus lej kos duab tshiab rau nws. Koj yuav tuaj yeem pom tias nws ua cov tswv yim thiab tso tawm (nkag siab txog qib kev nkag mus digital, tso tawm rau ntawm lub rooj tsav xwm LED); khaws thiab rov qab tus nqi los ntawm qhov tsis hloov pauv EEPROM nco. Txhua yam yam tsis txuas cov xov hlau lossis khoom siv.
  2. Muab kev lom zem thiab kev sib tw sib cuam tshuam nrog Arduino board.

Cov lus qhia no xav tias koj twb tau teeb tsa Arduino IDE thiab tsawg kawg paub tsawg nrog nws siv. Yog tsis yog kuv xa koj mus rau cov txuas no:

Pib Pib nrog Arduino

Ntxiv Digispark (nrog bootloader) txhawb rau Arduino 1.6.x IDE uas twb muaj lawm

Push-Nws yuav ua haujlwm nrog feem ntau ntawm Arduino board, xws li Nano, Uno, lossis DigiSpark Attiny85 board. Kuv tau sim nws nrog Nano 3.1 thiab DigiSpark.

Kauj Ruam 1: Muaj Yam Koj Yuav Tsum Tau

Uas yog ib qho yooj yim ib qho Arduino lossis pawg thawj coj sib piv.

Yog tias koj tsis muaj ib qho kuv xav kom pib nrog DigiSpark Pro (~ $ 12), lossis Nano 3.0 los ntawm eBay rau ~ $ 3 (tab sis koj yuav muaj ib lub lim tiam ntxiv lossis ob hnub tos nws los ntawm Tuam Tshoj; thiab koj yuav tsum teeb tsa CH340 USB tsav tsheb). DigiSpark ~ $ 10 (tsis yog Pro) zoo heev rau qhov ib qho me me 'video' game (Qhov kev tshem tawm no, tsuas muaj 6 I/Os, yog qhov ua kom me ntsis ntxiv rau)

Txuas mus rau kho vajtse siv nyob ntawm no:

Nano V3.0 Atmega328P ntawm eBay

Digispark USB Development Board

Kauj ruam 2: Nqa thiab rub tawm Cov Cai

Rub tawm thiab rub tawm Code
Rub tawm thiab rub tawm Code

Luam cov cai hauv qab no rau hauv cov ntaub ntawv kos duab arduino (piv txwv li…/Push_It/Push_It.ino) Kuv tau sim tawm tswv yim kom haum zoo. Kuv vam tias koj pom cov cai nkag siab yooj yim. Cov laj thawj los txiav txim siab thaum twg yuav nce ntxiv, txo qis thiab thaum twg tsis yog qhov nyuaj me ntsis, tab sis qhov ntawd kuj yog cov cai tshwj xeeb thiab tsis yog qhov muaj txiaj ntsig dav. Arduino IDE saib:

Tsim Tus Qauv Tshiab Arduino

Rub tawm qhov 'Push_It' kos duab rau hauv peb lub microcontoller raws li Arduino IDE cov lus qhia rau koj pawg thawj coj.

Kauj ruam 3: Ua si

Ua si
Ua si

Lub hom phiaj ntawm qhov kev ua si yog kom tau txais LED (ntawm lub nkoj) kom ntsais ntau lub sijhawm kom ntau li ntau tau hauv cov teeb uas tom qab ntawd rov ua dua.

Ua si qhov game:

Push-It pib tawm nrog ib qho nyem, uas yuav rov ua dua. Yog tias koj kov koj tus ntiv tes nyob ze tus pin nkag thaum LED qhib, lub voj voog tom ntej yuav nyem LED ob zaug.

Txhua lub sijhawm koj thawb lub pseudo khawm thaum lub sijhawm nyem thawj zaug ntawm cov teeb nyem ib qho ntxiv yuav ntxiv rau lub teeb ntawd. Feem ntau nws tsis muaj teeb meem thaum koj tsa/tshem koj tus ntiv tes.

Tab sis yog tias koj 'thawb' ua ntej lossis tom qab thawj zaug nyem qhov suav ntawm qhov muag hauv ib txheej yuav raug txo.

Yog tias koj tsis ua dab tsi ntxiv, tus naj npawb ntawm cov teeb nyob hauv ib txheej tau khaws tseg. Ntxiv mus thaum suav tsis hloov pauv rau lub voj voog tag nrho cov lej suav tau khaws cia rau hauv EEPROM nco.

Txhua lub sijhawm koj tswj kom nce lub flash suav lub sijhawm nrawm dua me ntsis, ua rau nws nyuaj thiab nyuaj kom nce mus txog qhov suav suav. Thaum koj ua tus swb thiab tus lej flashes tau txo qis yuav muaj kev ncua ntev dua ua ntej pib nyem ntawm lub voj voog tom ntej. Qhov no muab kev sib tw ntxiv, vim nws tuaj yeem ua rau koj muaj peev xwm dhia phom ntau dua. Yog li ceev faj.

Thaum koj tau txais koj chav nyob kom suav siab flash koj tuaj yeem nqa nws (lossis xa nws, uas yog DigiSpark zoo rau) rau tus phooj ywg, qhov twg thaum ntsaws nws hauv lawv yuav pom ntau npaum li cas flash suav koj tau txais koj li rau. Kuv tau pom nws txiav tawm qhov nyuaj kom tau txais nws ntau dua 8. Nrog lub khawm tiag tiag Kuv tau tswj kom tau nws ntau dua li kaum ob. Txhawm rau rov qab mus rau qhov suav qis dua koj tuaj yeem rov thawb nws txhua lub sijhawm ua ntej lossis tom qab thawj zaug nyem. Tsis tas li yog tias koj jumper tus pin nkag rau hauv av thaum lub zog nce suav yuav rov pib dua rau 1.

Nco ntsoov tias thawj daim DigiSpark pawg thawj coj tau ncua sijhawm 10 vib nas this tom qab lub zog ua ntej uas nws yuav pib ua qhov 'Push-It' code thiab ua si game. Nws siv lub sijhawm no los sim tham los ntawm USB pins txhawm rau kom tau txais qhov hloov tshiab tau rub tawm cov cai tshiab.

Yog tias Arduino pawg thawj coj uas koj siv muaj USB TX LED rau nws, cov LED no yuav muaj lub teeb nyem me me thaum koj ua tau zoo 'thawb lub pob'. Yuav muaj qhov tseem ceeb ntxiv ntawm qhov LED no thaum puas tau suav tus lej hauv EEPROM tau hloov kho nrog tus nqi tshiab. Cov lus tawm tswv yim no tuaj yeem pab koj zoo heev thaum paub lossis ua pov thawj tias koj tau ua tiav qhov tshwm sim 'thawb khawm'. Koj yuav tsum tau ua kom ntseeg tau tias koj tsis tau kov hauv av hauv av (zoo li cov hlau nyob ib puag ncig lub micro-USB txuas) yog li koj daim duab yeej ua rau muaj suab nrov ntawm qhov qhib tus pin nkag. Yuav muaj kev ntxiv thiab qee qhov teeb meem uas tsis tuaj yeem kwv yees tau vim tias tus lej nkag nkag tau ntab (tsis rub los lossis nqes los ntawm kev coj ua/tiv thaiv kev thauj khoom) thiab cov suab nrov sib txawv los ntawm koj tus ntiv tes.

Lub 250Hz square yoj tau tso tawm rau tus pin nyob ib sab ntawm tus lej nkag uas zoo heev txhim kho qhov tseeb ntawm kev txhaj tshuaj tawm suab thaum koj ntiv tes npog ob lub pins.

Kuv tau pom DigiSpark pawg thawj coj cov lus teb kom ua tau zoo ib yam tuaj yeem kwv yees me ntsis ntawm cov ntiv tes mus rau kaum ntawm pawg thawj coj saib qhov twg D3-D5 yog.

Thaum kuv ua si 'Push-It' Kuv nyiam ua li ntawd nrog lub rooj tsav xwm txuas nrog USB 5v lub roj teeb pob txawb (saib duab). Cov no feem ntau tuaj yeem pom tsis kim hauv cov thoob ntawm ib sab ntawm USB AC thiab 12v pib hloov kho; feem ntau ntawm txhua lub khw muag khoom siv hluav taws xob.

Kauj Ruam 4: Yeem Kev Xeem nrog Cov Txheej Txheem Sab Nraud

Yeem sim nrog Cov Cheeb Tsam Sab Nraud
Yeem sim nrog Cov Cheeb Tsam Sab Nraud

Thov nco tseg: Yog tias koj txuas lub pob tiag muaj ib kab kab uas yuav tsum tau tawm tswv yim, raws li tau hais hauv kab ntawv.

Nrog tus hais lus, ib sab rau hauv av, yog tias koj kov lwm txoj hauv kev rau D4 koj yuav hnov lub suab ntawm 250 Hz square yoj. Ntawm D3 muaj 500Hz square yoj. Yog tias koj txuas tus neeg hais lus ntawm D3 thiab D4 koj yuav hnov cov lus sib xyaw ntawm ob lub cim.

Hooking tus LED hloov ntawm tus hais lus raws li tau hais los saum no yog qhov nthuav heev. Tsis tas yuav tsum muaj kev txhawj xeeb txog qhov hluav taws xob, qib tam sim no, cov neeg tawm tsam, lossis tseem muaj qhov sib txawv rau qhov teeb meem (qhov xwm txheej tsis zoo nws tsis pom, tom qab ntawd tsuas yog tig nws ib ncig). Sim, ua ntej tshaj plaws, nrog qhov tsis zoo (cathode) txhuas txuas nrog hauv av thiab lwm qhov rau D3 lossis D4. LED yuav 'ib nrab' lit, vim yog cov xwm txheej tsis xwm yeem. Tsis tas yuav tsum muaj cov neeg tawm tsam raws li qhov tso tawm ntawm MicroControllerUnits tam sim no muaj txwv. Kuv tau ntsuas tam sim no ua rau 15ma thiab 20ma rau Attiny85 thiab Atmega328 MCUs feem. Cov qib no yog kwv yees li ib nrab ntawm cov nqi tam sim no rau cov khoom no vim 50% kev ua haujlwm lub voj voog ntawm kev tsav lub xwmfab yoj cov cim. Kev ntsuas lub ntsuas ntsuas yog qhov nruab nrab ntawm qhov tam sim no dhau los ntawm kev sim Circuit.

Qhov txaus siab, yog tias koj txuas nruab nrab ntawm D3 & D4 nrog LED (saib duab saum toj no thiab sab laug) nws yuav pom ob txoj kev, thiab txog ½ qhov ci ci zoo li nws tau ua nrog ib sab txuas rau hauv av. Kuv caw koj los xav txog vim li cas.

Pom zoo: