Cov txheej txheem:

Pong Ua Si Yooj Yim Yooj Yim Ntawm Lub Tsho: 8 Kauj Ruam (nrog Duab)
Pong Ua Si Yooj Yim Yooj Yim Ntawm Lub Tsho: 8 Kauj Ruam (nrog Duab)

Video: Pong Ua Si Yooj Yim Yooj Yim Ntawm Lub Tsho: 8 Kauj Ruam (nrog Duab)

Video: Pong Ua Si Yooj Yim Yooj Yim Ntawm Lub Tsho: 8 Kauj Ruam (nrog Duab)
Video: leej twg tej ntxhai - Mang Vang [ Official MV ] 2024, Kaum ib hlis
Anonim
Pong Ua Si Ncaj Ncees Ntawm Lub Tsho
Pong Ua Si Ncaj Ncees Ntawm Lub Tsho
Pong Ua Si Ncaj Ncees Ntawm Lub Tsho
Pong Ua Si Ncaj Ncees Ntawm Lub Tsho
Pong Ua Si Ncaj Ncees Ntawm Lub Tsho
Pong Ua Si Ncaj Ncees Ntawm Lub Tsho

Nov yog kuv qhov kev hnav khaub ncaws Xus rau xyoo 2013. Nws tau ua haujlwm txog li ib xyoos thiab tau siv ob peb teev tus txiv neej los tsim. Lub vijtsam yog 14 txog 15 pixels, yog li, daws teeb meem zoo nkauj tab sis nws tseem tuaj yeem ua qee yam lom zem. Nws yog lub cev yoog raws hauv txhua qhov kev qhia, txawm hais tias nws tsis tuaj yeem quav tau yam tsis muaj kev puas tsuaj. Nws muaj tus tswj hwm suav nrog ib lub pob thiab swb lub lauj kaub, txuas nrog rau pro mega ntawm USB. Txhawm rau kom nws muaj sia nyob ntev nws siv ob lub roj teeb 2200 mAh uas tsis muaj zog nyob hauv kab kom tau txais qhov tsim nyog qhov hluav taws xob, thiab tom qab ntawd 5 Volt tus tswj hwm kom nws siv tau. Txhua yam khoom siv hluav taws xob tau muab tso rau hauv hnab tshos sab hauv ntawm lub tsho kom lawv tuaj yeem raug tshem tawm thiab yog li lub tsho tuaj yeem ntxuav tau. Nws ua si lub luag haujlwm ntawm pong. Nws xub ua ib qho nrog cov lus "PONG PLAY" hauv cov ntawv zoo nkauj xiav siv qhov hloov pauv ntawm Tom Thumb font (tuaj yeem pom ntawm https://robey.lag.net/2010/01/23/tiny-monospace-font.html). Tom qab tsib vib nas this qhov kev xaiv tuaj yeem muab rau nias lub pob kom txav mus, lossis tsis txhob nias lub pob thiab tawm qhov kev paub zoo kawg nkaus tom qab. Thaum ib tus xaiv los nias lub pob, qhov kev ua si pib. Tus duav liab ntawm sab xis yog lub duav lub computer thiab lub duav ntsuab ntawm sab xis yog lub duav neeg uas ua ntawv, uas yog tswj los ntawm lub lauj kaub swb kom txav nce thiab nqis. Lub npas bounces ncig raws li txhua sab sim ua kom tau qhab nia. Tus neeg ua si tuaj yeem ntaus pob nrog ntug ntawm lawv lub duav kom nrawm dua (qhov zoo) thaum lub khoos phis tawj tsis tuaj yeem ua qhov no, thiab hloov qhov kawg mus nrog kev txav me ntsis qeeb dua pob. Thaum lub ntsiab lus tau qhab nia pixel hloov mus dawb ntawm cov qhab nia sab duav. Nws suav hauv binary los hauv qab. qhov twg ntsuab lossis liab yog xoom thiab dawb yog 1. 21 yog tus qhab nias kom yeej (lossis poob nyob ntawm seb leej twg tau txais 21 cov ntsiab lus) thiab yog li thaum tus neeg ncaws pob duav nyeem 10101, "Koj Yeej" cov ntawv tau tshwm. Ib zaug ntxiv hauv kev hloov Tom Thumb. Ib yam tshwm sim tab sis nrog "KOJ LOSEB" tso tawm qhov pom. Tom qab yeej lossis poob qhov kev ua si rov pib dua rau tom qab Pong Play. Txhawm rau rov pib dua lub pob pib dua ntawm "Magic Box", tseem hu ua-lub thawv-nrog-tagnrho-cov khoom siv hluav taws xob-tshwj tsis yog-lub-screen, raug nias.

Kauj Ruam 1: Cov Ntaub Ntawv thiab Cov Cuab Yeej

Cov Khoom thiab Cov Cuab Yeej
Cov Khoom thiab Cov Cuab Yeej
Cov Khoom thiab Cov Cuab Yeej
Cov Khoom thiab Cov Cuab Yeej

Yam cim nrog * yog nyob ntawm yeem tab sis pom zoo Thiab yog li tsis muaj kev xaj tshwj xeeb … Cov khoom siv: 4 Yards ntawm Adafruit Neopixle 60 pixle ib 'meter' strip 1 T-shirt * 1 khub Suspenders 1/2 yard ntawm cov ntaub yuav ntau dua li txaus (Tsis yog stretchy weave yog qhov zoo dua) 6 ko taw USB A txiv neej rau USB B txiv neej cable 1 USB A poj niam txuas 3 2 tus pin JST poj niam txuas 4 2 tus pin JST txiv neej xov hlau roj teeb them 2 6600 mAh roj teeb 1 Arcade style Button 1 arduino pro-mega 1 FTDI header 1 USB B poj niam txuas nrog lub rooj sib tsoo tawg 1 qhib/hloov (toggle) 1 rov pib dua (toggle lossis nrawm) 1 swb potentiometer *1 swb lub lauj kaub pob qhov rooj 1 siab amp txuas txuas *1 qhov project 1 5V 3+ amp qhov ntsuas hluav taws xob me me cov yas me me qee cov xaim qee cov xov *qee cov kua nplaum kub *qee lub sijhawm qee lub sij hawm (Tej zaum me ntsis ntau dua "qee qhov") qee qhov ua siab ntev (Koj yuav zaum xav tau me ntsis ntawm qhov tseeb no) qee qhov cua sov ntsws lossis cov kab xev hluav taws xob qee cov kua nplaum super hlau qee cov thim rov qab Cov cuab yeej *Pab txhais tes li ib txwm s (lossis ib tus neeg tuaj yeem nkag mus rau lawv) Soldering Iron *Hot Glue Gun Dremel lossis Sandpaper Chisel Wire Strippers Wire Cutters Staple Gun Screw Driver Saw Pins Sewing Machine Fabric Scisors

Kauj Ruam 2: Txiav LED Sawb rau hauv Cov Kab Me Me

Txiav cov LED Sawb rau hauv Cov Kab Me Me
Txiav cov LED Sawb rau hauv Cov Kab Me Me
Txiav cov LED Sawb rau hauv Cov Kab Me Me
Txiav cov LED Sawb rau hauv Cov Kab Me Me
Txiav cov LED Sawb rau hauv Cov Kab Me Me
Txiav cov LED Sawb rau hauv Cov Kab Me Me

Siv qhov koj nyiam txiav cov tais diav thiab txiav kab txaij rau hauv 14 ntu, txhua 15 pixels ntev. Cut tsuas yog nruab nrab ntawm cov tooj liab, sau ib yam dab tsi xws li "DO" "DIN" "+5V" thiab "GND". Yog tias nws twb tau siv dua cov tooj liab lawv tsuas yog txiav txoj cai los ntawm. Sim tsis txhob txiav ntau rau hauv cov tooj liab tab sis yog tias koj nick nws me ntsis uas yog qhov zoo xwb. Thaum tag nrho 14 ntawm kab txaij tau txiav, txiav me ntsis ntawm cov roj hmab tawm ntawm txhua qhov kawg kom nws tawm ntawm txoj hauv kev rau cov hlua txuas.

Kauj Ruam 3: Siv Lub Vev Xaib Ua Ke

Soldering Screen ua ke
Soldering Screen ua ke
Soldering Screen ua ke
Soldering Screen ua ke
Soldering Screen ua ke
Soldering Screen ua ke

Nqa cov xaim thiab txiav nws mus rau ntu 3.5 nti (9 cm) ntu. Hauv kuv qhov xwm txheej kuv muaj peb xim sib txawv los ua kom yooj yim kom ncaj thaum soldering, tab sis ib qho xim yuav ua haujlwm zoo xwb. Koj yuav xav tau txog 40 tus ntawm cov menyuam yaus no, tab sis txiav ob peb yam ntxiv xwb. Thaum Koj tau ua tiav kev txiav cov xaim, hle thiab xaum qhov kawg (Yog tias koj muaj kev paub zoo koj tuaj yeem hla mus rau kab lus tom ntej), lub ntsiab lus tom qab koj tshem cov yas me me tso qee qhov laug ntawm qhov kawg ntawm txhua lub xov hlau. Tsis txhob ua kom sov lub lauj kaub thiab sim txav mus rau xaim, ua kom sov nrog koj cov hlau txuas los ntawm hauv qab ntawm tooj liab thiab muab cov laug tso rau saum. Ua siab ntev thiab tos kom cov xov hlau kub yaj cov laug. Nws yog kev ntxias kom tawv cov hlau txhawm rau txhawm rau txhawm rau pib nws (Kuv lub siab tsis ncaj thiab kuv paub tseeb tias koj xav li cas) tab sis cov laug yuav tsis lo ib yam. Ua tib yam rau qhov pom tooj liab ntawm txhua qhov kawg ntawm ntu kab txaij. Yog tias nws twb muaj cov laug lawm tsis txhob txhawj txog nws. Rau kab txaij koj yuav xav tsim me ntsis mound kom yooj yim dua tom qab. Thaum ua haujlwm nrog kab txaij, ua sai sai, thiab sim tsis txhob siv sijhawm ntau los thov cov cua sov rau cov hlua. Tsuas yog ua qhov koj yuav tsum tau ua kom yaj cov laug rau hauv kab. Siv cov hlau xaim ntawm txhua txoj kab mus rau qhov kawg ntawm thawj kab txaij (Thawj kab txaij yog ib qho nrog cov xov hlau thiab txuas, txuas nws mus rau qhov kawg). Yog tias koj saib ntawm kab txaij koj yuav pom cov xub me me ntawm nws nce mus txog qhov kawg uas koj tau xaim hlau. Siv lwm txoj hlua kom cov xub tau taw qhia qhov tsis sib xws, thiab muab cov xaim txuas los ntawm GND taug qab mus rau GND kab ntawm lwm qhov, tus +5V rau +5V thiab ntxiv rau. Rov ua qhov no kom ntseeg tau tias cov xub hloov cov lus qhia tom qab txhua ntu kom yog tias koj yuav tsum ua raws lawv nws yuav zig zag nce thiab nqis, thiab tias nws tuaj yeem nthuav tawm mus rau ntawm cov kab ntev hauv qhov kawg. Thaum tag nrho 14 daim kab xev tau muab muag lawm, tso lawv tawm thiab kab tom qab ntawd kom LED ua daim phiaj. Tom qab ntawd khaws lawv ua ke siv txoj hauv kev uas tuaj yeem tshem tawm tom qab yam tsis muaj kev puas tsuaj rau cov kab txaij. Kuv siv daim kab xev scotch. Nws yog nplaum txaus kom ua txhua yam ua ke tab sis tsis nplaum li kom tawm qhov seem. Kuv tsis hais qhia ib yam dab tsi rau qhov ruaj khov, zoo li cov hlua khi lossis cov kab xev. Thaum txhua yam tau raug kaw ua ke txuas lub xaim los ntawm kab txaij hauv qab +5V rau ib qho tam sim ntawd ntawm nws. Rov ua dua kom txog rau thaum tag nrho hauv qab muaj lub zog fais fab mus rau txhua txoj kev hla. Qhov no yog li lub vijtsam tsis dim raws li kab ntawm LEDs nce qib.

Kauj Ruam 4: Soldering Core Electronics

Soldering Core Electronics
Soldering Core Electronics
Soldering Core Electronics
Soldering Core Electronics
Soldering Core Electronics
Soldering Core Electronics

Solder USB B breakout board (BOB) rau USB B txuas. Muab cov xov hlau uas tsim nyog txuas rau USB A txuas. Kuv qhia saib tus pin-out ntawm tus txuas raws li pom ntawm lub vev xaib no, https://image.pinout.net/pinout_USB_files/pc_usb_connectors_pinout.png. Tsis txhob txhawj txog qhov yuav muab lwm qhov xaus ntawm cov xov hlau txuas ntawm USB A txuas tam sim no; uas yuav raug them rau hauv cov kauj ruam tswj. Txiav cov ntaub ntawv txuas los ntawm kab txaij, poj niam txuas, tsis yog txiv neej txuas (Tus poj niam txuas tau los ntawm lwm qhov kawg). Muab tus txiv neej JST txuas rau qhov kawg ntawm lub roj teeb kom liab mus liab thiab dub mus dub. Cov cua sov ua kom sov tubing hla cov xov hlau nthuav tawm (swb dhau ua ntej yuav siv tau) kom lawv tsis txhob luv lossis siv lwm yam xws li kab xev hluav taws xob lossis kua nplaum kub. Siv cov xov hlau txuas rau txhua tus poj niam JST txuas. Nco ntsoov kom muaj tus txiv neej kawg ntsaws kom lub pins tsis hloov pauv ib puag ncig. Ceev faj ntawm polarity thiab xyuas kom cov xov hlau sib phim nrog cov txiv neej txuas. Cov kab hluav taws xob txuas rau ib qhov txuas hluav taws xob siab (tab sis tsis yog nws khub), ib zaug ntxiv, ua kom ntseeg tau tias muaj xim sib phim thiab tias lawv tau txuas ua ke txhawm rau tiv thaiv ib qho kev hloov pauv. Solder tus poj niam tsuas yog txuas/xaim sib dhos kom lawv tau xaim hauv kab, tsis sib xws, kom tau nws dhau qhov pib qhov hluav taws xob rau lub zog tswj hwm. Yog li, muab cov xaim hluav taws xob zoo rau cov xaim tsis zoo ntawm lwm lub rooj sib txoos tam sim no peb muaj ib qho tsis xaim hluav taws xob zoo thiab ib qho xaim tsis xaim hlau tsis zoo thiab ob lub xaim xaim txuas tau txuas rau sib txuas sib txawv. Nqa cov xaim tsis zoo thiab txuag nws kom muab muag rau cov xaim tsis zoo mus rau lwm qhov. Tam sim no coj cov hlau zoo thiab muab nws txuas rau qhov hloov Yog tias muaj peb lossis ntau tus pin (lossis ntau dua ib txoj hauv kev ua "ntawm") muab nws txuas rau tus pin nruab nrab. Nco tseg "Tus pin nruab nrab" yuav tsis yog lub cev nyob nruab nrab. Txoj hauv kev los txheeb xyuas nws yog txhawm rau nrhiav tus pin uas, thaum hloov mus rau hauv ib lub xeev twg yuav txuas nrog lwm tus pin. Yog tias tsis muaj tus pin zoo li no ces koj muaj qhov hloov tshwj xeeb heev; tsuas yog txuas nws rau ib tus pin thiab xyuas kom tseeb tias cov xaim txuas tom ntej mus rau qhov hloov pauv yuav txuas nrog lub xov tooj ntawd tsawg kawg ib ntawm lub xeev. Tam sim no muab cov xov hlau zoo tso rau ntawm tus tswj qhov hluav taws xob mus rau qhov kawg ntawm qhov hloov pauv, raws li tau tham los saum no. Siv cov khoom siv hluav taws xob tom qab tawm mus rau qhov kawg ntawm qhov tsis txuas nrog lub siab tam sim no txuas. Siv cov xov hlau tsis zoo thiab muab nws txuas rau qhov tsis zoo ntawm qhov txuas tam sim no. Tam sim no peb tab tom yuav siv lub zog txuas nrog rau Arduino thiab Lub Hwj Chim Sawb. Tam sim no coj tus tswj hwm qhov hluav taws xob tso tawm cov xov hlau thiab txuas ob daim hlau ntawm ob qho tib si qhov zoo thiab qhov tsis zoo kom lawv tawm hauv cov duab Y. Solder ob tus pin txuas rau qhov zoo thiab tsis zoo ntawm cov coj coj los ua ke. Nws tsis muaj teeb meem dab tsi hom txuas koj siv, nws tuaj yeem yog JST lossis hauv kuv qhov xwm txheej qee lub zog/suab cable lossis qee yam (Kuv tsis paub tseeb, thiab kuv thov txim uas tsis muaj duab). Muab ib qho ntawm cov xov tooj hluav taws xob zoo mus rau qhov kawg ntawm qhov txuas sib txawv rau lub teeb ci thiab ib qho ntawm cov xov tsis zoo mus rau lwm tus pin ntawm qhov txuas. Ua tib yam tab sis rau tus txiv neej JST txuas/xaim sib dhos. Txhua lub sijhawm nco ntsoov txhawm rau txhawm rau txhawm rau txhawm rau txhawm rau txhawm rau zam qhov luv. Tam sim no mus rau qhov yuav ua li cas nrog USB B txuas. Muab cov hlau zoo rau lub 5v qhov ntawm Arduino Pro Mega. Nqa cov xaim av thiab muab nws txuas rau qhov GND. Coj tus D+ thiab txuas nws mus rau tus lej digital (lossis hauv qhov no, qhov) 40. Cov laug D- rau tus pin sib piv 15. Luag cov ntaub ntawv kawg ntawm tus poj niam txuas uas mates nrog LED sawb txiv neej txuas rau cov ntaub ntawv tus pin 6 thiab xaim av rau GND tus pin. Kev npog ntsej muag lossis daim kab xev ua haujlwm zoo rau tuav cov xov hlau mus rau lub rooj tsavxwm kom lawv tsis poob tawm thaum nws tig mus rau qhov muag. Tam sim no siv lub khawm me ntsis thiab muab cov xaim txuas los ntawm ib kawg rau VCC tus pin (lossis ib qho pin tso zis hluav taws xob) thiab lwm qhov kawg rau tus pin RESET.

Kauj ruam 5: Tswj

Maub los
Maub los
Maub los
Maub los
Maub los
Maub los

Thawj yog xaiv lub cev kom raug los pib nrog. Txhua yam nws nyob ntawm seb koj xav kom tus tswj hwm teeb tsa li cas. Kuv xav tau ntau tus tswj kev tiaj tus yog li kuv tau txais ib daim ntawm 3 1/2 "los ntawm 3/4" plank. npaj cov ntu hauv txoj hauv kev uas zoo li haum thiab nyiam ua haujlwm nrog. Siv txoj kab nkhaus Fab Kis, daim duab peb sab, daim duab peb sab, thiab ntug ncaj kom kos qhov twg txhua daim yuav tsum mus. Txiav cov qauv yooj yim tawm siv cov cuab yeej txiav ntawm qhov koj xaiv. Qhov txiav npluav pom yuav zoo tshaj plaws tab sis kuv siv lub rooj sib hais, uas ua haujlwm tau zoo xwb. Xuab zeb hauv qab los ua kom lawv hloov pauv tau yooj yim, tom qab ntawd xuab zeb nqes los ua kom nws xis nyob dua. Laum tawm lub qhov rau qhov hloov pauv, tom qab ntawd xuab zeb, txhoov, thiab/lossis Dremel tawm ib feem hauv qab uas yuav ua rau nws haum. Sim tsis txhob ua dab tsi nrog rau sab saum toj thiab tsuas yog xuab zeb tawm qhov koj xav tau kom muaj peev xwm ua kom haum nws los ntawm kev sib tw, sib tw, lossis lwm yam kom nws nkag mus. Thaum nws txuas nrog lub txiv ntoo yas thiab txuas hloov. Laum tawm thaj chaw rau lub pob qhov taub kom haum los ntawm thiab txov tawm thaj chaw kom nws tuaj yeem nkag rau hauv thiab haum txhua txoj hauv kev. Laum tawm qee qhov kom cov ntsia hlau tuaj yeem tuav tau. Khoov hauv qhov me me ntawm USB A txuas uas ua rau nws dav dav nce me ntsis (saib cov duab). Chisel tawm ib feem rau qhov txuas, txuas ntxiv tshuaj xyuas kom paub tseeb tias lub txuas haum. Super nplaum cov txuas rau hauv nws lub qhov. Siv me me ntawm cov yas thiab txiav nws mus rau hauv cov duab uas yuav haum rau ntawm qhov txuas (saib cov duab), thiab tom qab ntawd muab nws txuas rau ntoo. Txiav tawm tej daim uas yuav tau txais txoj hauv kev. Ntsia hauv potentiometer thiab txuas lub pob qhov rooj. Muab cov xaim hluav taws xob zoo rau ib qho ntawm qhov xaus ntawm lub hwj chim (tsis yog qhov sib txawv) thiab xaim tsis zoo rau qhov kawg. Solder D-pin rau tus pin sib txawv ntawm lub lauj kaub. Siv lub xaim hlau los ntawm tus pin ntawm lub lauj kaub nrog cov xaim zoo rau ib qho ntawm tus pin ntawm lub pob. Solder D+ rau lwm tus pin ntawm lub pob. Txiav cov hlau seem thiab thaiv cov khoom uas xav tau.

Kauj Ruam 6: Lub tsho

Lub tsho
Lub tsho
Lub tsho
Lub tsho
Lub tsho
Lub tsho

Nrhiav lub tsho zoo uas yuav tso lub teeb dhau mus. Kuv xaiv lub tsho T-shirt dawb no. Nws tsis muaj teeb meem xim lossis style ntev li ntev tau pom lub teeb ci tuaj ntawm sab hauv. Txawm li cas los xij kuv tsis pom zoo cov duab ntawm sab xub ntiag. Teem tawm txhua yam ntawm lub tsho kom pab koj txiav txim siab qhov twg koj xav tau thiab siv lub cuab yeej lwv tawm los kos nws. Kuv (lub ntsiab lus qee tus neeg kuv paub) muaj tus xaum ntawv txhais tau tias kos cov ntaub uas ntxuav tau yooj yim. Ntsuas qhov loj ntawm lub roj teeb, cov ntaub ntawv tswj, thiab tshuaj ntsuam thiab txiav tawm daim ntawv kom haum. Tom qab ntawd khawm daim ntawv rau ib daim ntawm cov ntaub uas tsis ncab. Ib txoj hlua ua haujlwm zoo rau qhov no. Tom qab ntawd txiav tawm cov duab plaub tawm ntawm ib feem peb ntiv tes rau txoj hlua ib ncig. Tom qab ntawd siv daim ntawv los ua cov lus qhia hlau cov quav rau hauv cov ntaub. Tam sim no daim ntawv tuaj yeem raug tshem tawm. Ntawm ib sab ntawm lub hnab tshos uas yuav yog sab saum toj nws hla nws tus kheej peb zaug. Hlau thiab khawm nws kom nws nyob hauv qhov chaw. Xaws ib qho zoo li txhua txoj hauv nruab nrab ntawm txoj hlua. Tam sim no coj lub ces kaum thiab quav nws kom cov ntug uas tsis tau xaws ncaj rau ib leeg sib txig sib luag thiab xaws ib qho zoo li raws cov hlau uas nyob ze rau ntawm lub ces kaum (Cov duab yeej pab tau). Ua qhov no rau lwm ces kaum ib yam nkaus. Yog tias muaj xwm txheej koj yuav muaj lub toggle hloov los ntawm lub hnab tshos, xaws lub pob qhov nyob ntawm lub hauv paus ntawm lub hnab tshos qhov twg hloov mus kov. Tom qab ntawd xaws lub pob qhov thiab txiav tawm qhov nruab nrab. Kuv tsis tuaj yeem muab cov lus qhia ntxaws vim tias kuv muaj lub cuab yeej txias los ua khawm qhov. Tsuas yog xyuas kom koj ua lub qhov ua ntej lub hnab ntim tau xaws. Nqa qee tus pin thiab txhuam lawv los ntawm lub tsho ntawm cov ces kaum ntawm cov cim rau lub hnab tshos. Nqa lub hnab tshos thiab muab txhua lub ces kaum ntawm tus pin (nyob rau sab hauv ntawm lub tsho), tawm hauv peb lub hlis nti rau txoj hlua, thiab khawm nws rau lub tsho. Tom qab lub hnab tshos tau khawm. tshem cov pins tsis tuav lub hnab tshos thiab xaws lub hnab tshos rau lub tsho. Rov ua dua rau txhua lub hnab ris. Rau lub hnab ntim loj tuav lub vijtsam tawm qhov sib txawv rau cov xov hlau nyob hauv qab ntawm lub hnab tshos. Txhawm rau muab lub qhov tso rau hauv lub tsho kos rau qhov chaw thiab nqa hlau rau nraub qaum (nrog qhov ci ntsa iab ntawm daim ntaub) thiab hlau nws. Tom qab ntawd, rau lub qhov me me (zoo li qhov kuv tau siv rau qhov hloov pauv), ua lub pob qhov. Rau qhov loj dua, kos tus qauv thiab siv zigzag plooj raws kab (lossis nkhaus lossis koj muaj dab tsi) thiab txiav tawm ib nrab. Yog tias koj xav tau koj tuaj yeem siv cov khoom tshem tawm los tuav qhov hnyav ntawm lub hnab ris, ob daim yeeb yaj kiab tuav mus rau lub hnab ris ntawm sab xub ntiag thiab sab nraub qaum rau lub ris. Kuv kuj tau txais lub tes tsho me me ntawm cov ntaub xaws hla ib feem ntawm cov khoom raug tshem tawm uas yuav kov kuv cov tawv nqaij. Ob lub tsho tuaj yeem kub me ntsis yog li kuv tau xaiv tawm thiab siv lub tes tsho me me.

Kauj ruam 7: Programming

Programming
Programming

Thiab ntawm no yog cov cai. Muaj qee qhov uas tau hais zoo tab sis feem coob tsis yog. Yog tias koj muaj lus nug ntawm ntau qhov chaw koj tuaj yeem muab tus lej kab rau kuv (nrog #suav nrog ua kab naj npawb ib) lossis muab daim ntawv theej ntawm kab (s) rau kuv thiab ua haujlwm uas nws nyob (zoo li lub voj () lossis compMovePaddle ()) thiab kuv yuav ua kuv qhov zoo tshaj plaws los piav qhia rau koj, tom qab ntawv ntxiv cov lus rau tus lej piav qhia nws. #suav nrog #define PIN 6 // hais uas yog cov pins nkag rau qhov kev ua si int buttonPin = 40; // hais cov qhab nia, khaws cia hauv cov bianary array vim nws yog esier int playerScore [5] = {0, 0, 0, 0, 0}; int compScore [5] = {0, 0, 0, 0, 0}; // dictates lub pob qhov kev taw qhia int bvd = 0; // 0 nqis, 1 nce int bhd = 0; // 0 yog txoj cai, 1 yog sab laug // dictates lub pob txoj haujlwm int bvp = 8; sib bhp = 6; // txheeb xyuas seb lub pob puas nyob rau hauv hom nrawm boolean nrawm = tsis tseeb; // txheeb xyuas yog tias nws yog tus qhab nia. boolean cIsPoint = tsis tseeb; boolean pIsPoint = tsis tseeb; // duav txoj haujlwm int cPaddle = 0; int pPaddle = 0; ntev yav dhau losMillis = 0; ntev dhau losMillisForComp = 0; // teeb tsa lub sijhawm ncua kom nrawm thiab qeeb txav pob "Int" hauv normInt thiab fastInt yog rau ntu ntu normInt = 50; int fastInt = 10; // siv los txheeb xyuas qhov yeej. 1 yog neeg uas ua ntawv yeej, -1 hauv computer yeej, thiab 0 yog tsis muaj dab tsi tau tshwm sim tsis tau int yeej = 0; // kom tshem tawm kab. siv hauv cov lus hais ntxiv thiab tsis pom qhov twg ntxiv. int uas = 0; // Yam tso tawm ua ntej pib, -1 yog kev khiav tawm int pongPlay = {1, 2, 3, 4, 10, 11, 12, 13, 16, 18, 20, 27, 29, 33, 34, 41, 42, 61, 62, 63, 70, 71, 72, 76, 85, 86, 88, 91, 92, 94, 100, 101, 102, 103, 131, 132, 136, 139, 144, 145, 146, 147, 148, 161, 162, 166, 175, 183, 185, 192, 194, 195, 196, 197, 198, 199, 204, 205, 206, 207, 208, -1}; // yog tias koj yeej int kojWin = {1, 2, 3, 4, 5, 16, 17, 18, 19, 20, 27, 33, 34, 39, 46, 47, 48, 49, 54, 55, 56, 57, 58, 77, 78, 79, 84, 88, 91, 92, 93, 94, 95, 99, 103, 106, 110, 114, 118, 130, 131, 132, 144, 145, 146, 147, 151, 162, 163, 168, 169, 170, 177, 181, 192, 193, 204, 205, 206, 207, -1}; // yog tias koj poob koj poob = {1, 3, 5, 16, 17, 18, 19, 20, 24, 26, 28, 31, 32, 32, 32, 33, 34, 35, 39, 46, 47, 48, 49, 62, 65, 77, 78, 79, 84, 86, 88, 91, 94, 99, 103, 106, 110, 122, 123, 124, 130, 131, 132, 144, 148, 152, 153, 154, 162, 163, 168, 169, 170, 181, 192, 193, 204, 205, 206, 207, 208, -1}; // teeb tsa cov kab coj coj Adafruit_NeoPixel strip = Adafruit_NeoPixel (210, PIN, NEO_RGB + NEO_KHZ800); // teeb tsa, tig tsis muaj tus pin 40 rau kev nkag, pib kab ntawv, qhia txog // lus thiab qhia nws. teeb tsa tsis muaj dab tsi () {pinMode (buttonPin, INPUT); strip.begin (); rau (int i = 0; pongPlay > 0; i ++) {strip.setPixelColor (pongPlay , strip. Color (0, 0, 255))); } strip.show (); ncua (5000); thaum (digitalRead (buttonPin) == LOW) {// Nws yog ib qho cuab! (kom txog thaum lub pob nyem.)}} void loop () {clearScreen (); // thim cov paddles kom pom cov qhab nia rau (int i = 0; i <5; i ++) {if (playerScore == 1) {strip.setPixelColor (204-i, strip. Color (255, 255, 255)); } lwm tus yog ((playerScore == 0)) {strip.setPixelColor (204-i, strip. Color (0, 255, 0))); } yog (compScore == 1) {strip.setPixelColor (5+i, strip. Color (255, 255, 255))); } lwm tus yog ((compScore == 0)) {strip.setPixelColor (5+i, strip. Color (255, 0, 0))); }} // kos lub pob hauv nws pib txoj haujlwm strip.setPixelColor (98, strip. Color (255, 255, 255)); strip.show (); // txiav txim siab yog tias lub pob yuav nce lossis nqis thaum (pIsPoint == cuav && cIsPoint == cuav) {clearScreen (); unsigned ntev currentMillis = millis (); // muab tus neeg ua haujlwm duav txoj haujlwm pPaddle = checkPaddlePos (); // txheeb xyuas txoj haujlwm tom ntej checkNext (); // txav lub pob yog (nrawm == tsis tseeb) {yog (currentMillis - yav dhau los Millis> normInt) {yav dhau losMillis = currentMillis; moveBall (); }} lwm qhov yog (nrawm == tseeb) {yog (currentMillis - yav dhau los Millis> fastInt) {yav dhau losMillis = currentMillis; moveBall (); }} // kos lub pob yog (bhp%2! = 0) {strip.setPixelColor (bhp*15+14-bvp, strip. Color (255, 255, 255))); } lwm yog (bhp%2 == 0) {strip.setPixelColor (bhp*15+bvp, strip. Color (255, 255, 255))); } // computer duav txav compMovePaddle (); // kos tus paddles drawPaddles (); // actualy tso txhua yam tseg.strip.show (); // txheeb xyuas seb puas tau qhab nia yog (pIsPoint == tseeb) {uas = 0; bhd = 0; addOne (); tawg; } lwm yog (cIsPoint == muaj tseeb) {uas = 1; ib = 1; addOne (); tawg; }} yog (yeej == 1) {clearScreen (); rau (int i = 0; youWin > 0; i ++) {strip.setPixelColor (youWin , strip. Color (255, 0, 0))); strip.show (); } ncua (5000); rau (int i = 0; i <5; i ++) {playerScore = 0; compScore = 0; } yeej = 0; } lwm yog (yeej == -1) {clearScreen (); rau (int i = 0; youLose > 0; i ++) {strip.setPixelColor (youLose , strip. Color (0, 255, 0))); strip.show (); } ncua (5000); rau (int i = 0; i <5; i ++) {playerScore = 0; compScore = 0; } yeej = 0; } pIsPoint = tsis tseeb; cIsPoint = cuav; npv = 8; bhp; 6 ib. bvd = random (0, 2); // 0 nqis, 1 nce nrawm = tsis tseeb; } // AI rau qhov kev ua si tsis muaj dab tsi compMovePaddle () {unsigned ntev currentMillis = millis (); yog (currentMillis - yav dhau los MillisForComp> 51) {yav dhau losMillisForComp = currentMillis; yog (bvp> = 13 && 10-cPaddle 0) {cPaddle--; } lwm yog (bvp = 0 && cPaddle <10) {cPaddle ++; } lwm yog (bvp-3> 10-cPaddle && 10-cPaddle> = 0 && cPaddle> 0) {cPaddle--; } lwm yog (bvp <10-cPaddle && 10-cPaddle <= 10) {cPaddle ++; }}} // txav lub pob tsis muaj dabtsis moveBall () {yog (bhd == 0) {bhp--; } lwm yog (bhd == 1) {bhp ++; } yog (bvd == 0) {bvp--; } lwm yog (bvd == 1) {bvp ++; }} // ntxiv ib qho rau kab lus. Yog qhov twg yog 0 nws ntxiv rau tus neeg ua si cov qhab nia. Yog tias nws yog 1 nws ntxiv rau cov khoos phis tawj tsis muaj dab tsi addOne () {yog (uas == 0) {// yog tias nws yog tus neeg ntaus kis las // ntxiv ib qho. Nov yog txoj kev yooj yim uas kuv paub yuav ua li cas. rau (int i = 0; i <5; i ++) {// loop yog (playerScore == 0) {// yog tias tus nqi ntawd yog xoom playerScore = 1; // ua kom nws tawg 1; // ces ploj mus} lwm yam {// yog tias nws yog 1 playerScore = 0; // ua rau nws xoom thiab voj}}} lwm qhov yog (uas == 1) {rau (int i = 0; i <5; i ++) {if (compScore == 0) {compScore = compScore +1; tawg; } lwm {compScore = 0; }}} // Txheeb xyuas seb leej twg yeej. yog (compScore [0] == 1 && compScore [2] == 1 && compScore [4] == 1) {yeej = -1; } lwm tus yog (playerScore [0] == 1 && playerScore [2] == 1 && playerScore [4] == 1) {yeej = 1; }} // txheeb xyuas cov pob tom ntej txoj hauj lwm tsis muaj dab tsi checkNext () {// kos rau saib seb puas tau qhab nia yog tias (bhp == 13) {pIsPoint = tseeb; } lwm yog (bhp == 0) {cIsPoint = tseeb; } // yog tias lub ntsiab lus tau qhab nia hla hla cov khoom no yog (pIsPoint == cuav || cIsPoint == cuav) {// txheeb xyuas lub pob ntsug yog tias (bvp+bvd == 15) {bvd = 0; } lwm yog (bvp+bvd == 0) {bvd = 1; } // txheeb xyuas lub pob horizontaly yog (bhp+bhd == 13) {// ua ntej ntawm lub computer sab yog (bvp> = 10-cPaddle && bvp <= 10-cPaddle+4) {if (bhd == 1) {ib = 0; } lwm yog (bhd == 0) {bhd = 1; } ceev = tsis tseeb; } lwm tus yog (bvp+bvd == 10-cPaddle || bvp+bvd == 10-cPaddle+5) {yog (bvp! = 0 && bvp! = 14) {yog (bvd == 0) {bvd = 1; } lwm yog (bvd == 1) {bvd = 0; } ib = 1; } lwm yog (bvp == 0 || bvp == 14) {bhd = 1; } ceev = tsis tseeb; }} lwm tus yog (bhp+bhd == 1) {// tom qab ntawm tus neeg ua si sab yog (bvp> = pPaddle && bvp <= pPaddle+4) {// nws puas tsoo lub duav hauv qhov chaw ib txwm muaj? // thawb lub pob! yog (bhd == 1) {bhd = 0; } lwm yog (bhd == 0) {bhd = 1; }} lwm tus yog (bvp+bvd == pPaddle || bvp+bvd-5 == pPaddle) {// yog nws tsoo lub duav ntawm lub ces kaum yog (bvp! = 0 && bvp! = 14) {// yog tsis nce siab lossis qis qis? // Dhia pob! yog (bvd == 0) {bvd = 1; } lwm yog (bvd == 1) {bvd = 0; } ib = 1; ceev = tseeb; } lwm tus yog (bvp == 0 || bvp == 14) {// nws nce siab lossis nqis qis? // thawb lub pob! bhd = 0; nrawm = muaj tseeb; // teeb tsa tus nqi kom tom qab ua kom lub pob txav nrawm}}}}} int checkPaddlePos () {// nyeem lub lauj kaub thiab txiav txim siab ntawm txoj haujlwm duav raws li yog (analogRead (A15) <93) {rov qab 0; } lwm yog (analogRead (A15) <186) {rov qab 1; } lwm tus yog (analogRead (A15) <279) {rov 2; } lwm yog (analogRead (A15) <372) {rov 3; } lwm yog (analogRead (A15) <465) {rov 4; } lwm tus yog (analogRead (A15) <558) {rov 5; } lwm tus yog (analogRead (A15) <652) {rov 6; } lwm tus yog (analogRead (A15) <745) {rov qab 7; } lwm tus yog (analogRead (A15) <837) {rov qab 8; } lwm yog (analogRead (A15) <= 931) {rov qab 9; } lwm yog (analogRead (A15) <= 2014) {rov qab 10; }} void drawPaddles () {// kos tus paddles hauv qhov chaw raug thiab qhia cov qhab nia ntawm tus duav rau (int i = 0; i <5; i ++) {if (playerScore == 1) {strip. setPixelColor (pPaddle+i, strip. Color (255, 255, 255)); } lwm tus yog ((playerScore == 0)) {strip.setPixelColor (pPaddle+i, strip. Color (255, 0, 0)); } yog (compScore == 1) {strip.setPixelColor (199+cPaddle-i, strip. Color (255, 255, 255))); } lwm tus yog ((compScore == 0)) {strip.setPixelColor (199+cPaddle-i, strip. Color (0, 255, 0))); }}} void clearScreen () {rau (int i = 0; i <= 210; i ++) {strip.setPixelColor (i, strip. Color (0, 0, 0))); } strip.show (); }

Kauj Ruam 8: Ua tiav Cov Khoom

Tiav Khoom
Tiav Khoom
Tiav Khoom
Tiav Khoom

Thiab koj mus, lub tsho tiav!

Pom zoo: