Cov txheej txheem:

Handheld Arduino Paper Rock Scissors Game Siv 20x4 LCD Zaub Nrog I2C: 7 Kauj Ruam
Handheld Arduino Paper Rock Scissors Game Siv 20x4 LCD Zaub Nrog I2C: 7 Kauj Ruam

Video: Handheld Arduino Paper Rock Scissors Game Siv 20x4 LCD Zaub Nrog I2C: 7 Kauj Ruam

Video: Handheld Arduino Paper Rock Scissors Game Siv 20x4 LCD Zaub Nrog I2C: 7 Kauj Ruam
Video: Arduino Rock, paper, scissors game 2024, Hlis ntuj nqeg
Anonim
Handheld Arduino Paper Rock Scissors Game Siv 20x4 LCD Zaub Nrog I2C
Handheld Arduino Paper Rock Scissors Game Siv 20x4 LCD Zaub Nrog I2C
Handheld Arduino Paper Rock Scissors Game Siv 20x4 LCD Zaub Nrog I2C
Handheld Arduino Paper Rock Scissors Game Siv 20x4 LCD Zaub Nrog I2C
Handheld Arduino Paper Rock Scissors Game Siv 20x4 LCD Zaub Nrog I2C
Handheld Arduino Paper Rock Scissors Game Siv 20x4 LCD Zaub Nrog I2C

Nyob zoo txhua tus lossis tej zaum kuv yuav tsum hais "Nyob Zoo Ntiaj Teb!"

Nws yuav yog kev zoo siab los qhia ib qhov haujlwm nrog koj uas yog kuv nkag mus rau ntau yam khoom Arduino. Nov yog qhov khoom siv tuav Arduino Paper Rock Scissors game siv I2C 20x4 LCD zaub. Kuv paub koj yuav xav, "Lwm Daim Ntawv Pob Zeb Txiab game?" Tab sis feem ntau Arduino Paper Rock Scissors games siv cov LEDs yooj yim thiab kuv kuj tau pom ib qho uas siv cov ntawv cim cim nqa los ntawm servos. Cov ntawd txias. Txoj haujlwm no siv 20x4 LCD zaub thiab ua ib qho nrog I2C thiab ib qho tsis muaj nws (tsis pom ntawm no). Xav tau cov ntaub ntawv pheej yig nrog qhov ua tiav, tsis yog tsuas yog qhob cij-board tsis meej. Tsis yog txhua tus tau nkag mus rau lub tshuab luam ntawv 3D thiab xav them ib tus neeg uas ua. Thiab kuv xav kom nws yooj yim los ua kom kuv tuaj yeem faib cov tswv yim nrog lwm tus. Txij li thaum kuv cov txuj ci txuj ci yog qib tshiab tus kos duab yog qhov yooj yim zoo nkauj thiab nkag siab yooj yim thiab hloov kho. Nov yog kuv tus kheej txoj kev kawm los tsim cov duab kos. Koj yuav pom ntau cov ntawv sau hauv daim duab thiab nws tau dhau los ntawm ntau, ntau (20+?) Rov ua dua kom txog thaum kuv ntseeg tias nws yog qhov yog. Txoj haujlwm raug nqi tsawg dua $ 20 los ua (tsis yog I2C).

Tau pib nrog Arduino xyoo 2018 thiab dhau los ntawm lawv lub vev xaib thiab nyeem txhua yam kuv ua tau. Ua thiab sim nrog cov phiaj xwm piv txwv nws los nrog thiab nyeem ntau Cov Lus Qhia yog li ntau ntawm koj tau sib koom ntau xyoo. Txaus siab rau lawv tiag tiag thiab tau kawm ntau yam los ntawm koj txhua tus. Ua tsaug. Tam sim no kuv xav qhia qee yam uas kuv tau kawm ntxiv kuv tus kheej kev muaj tswv yim. Ua ntej cov lus pom hauv pawg suav nrog ntau cov lus nug yuav ua li cas thiab qhov ntawd thov nco ntsoov, Kuv pib qhov no yam tsis muaj kev paub dhau los hauv Arduino. Kuv kawm los ntawm kev tsim cov phiaj xwm piv txwv ntawm Arduino thiab Cov Ntawv Qhia Qhia lub vev xaib. Kuv tau kawm los ntawm koj. Thaum koj tau nyam cov ntawd tej zaum yuav yog txoj hauv kev nrawm tshaj plaws rau koj los nrhiav kev daws teeb meem.

Kauj Ruam 1: Kev Taw Qhia

Kev Taw Qhia
Kev Taw Qhia
Kev Taw Qhia
Kev Taw Qhia

Xaiv lub LCD zaub los ntawm Amazon thiab xaiv I2C 20x4 LCD vim tias tus nqi qis (kwv yees li $ 12 - $ 18) thiab yooj yim ntawm thaiv thiab phiaj xwm. Yog tias koj xav tau, koj tuaj yeem siv ib qho uas tsis muaj I2C thiab yuav tau txais ib qho pheej yig li $ 7. Tab sis koj yuav tsum tau siv lub tsev qiv ntawv sib txawv thiab cov phiaj xwm thaiv thiab siv ntau tus pin Arduino. Tsis txhob txhawj xeeb, nws tau txaus los mus ib txoj kev. Serial I2C 20x4 yuav yooj yim dua los tsim, tsawg dua cov xov hlau tsis tshua meej pem. Tab sis thaum uas tig mus 20x4 LCD yog kwv yees li $ 5 pheej yig dua. Kuv kos cov duab kos rau ob qho kev thaiv kab thaiv. Feem ntau ntawm lwm qhov kuv tau yuav los ntawm Amazon thiab ob peb lub khw muag khoom hauv zos. Kuv lub thawv yog khoob cappuccino haus lub thawv sib xyaw. Kuv nyiam tias lub hau yooj yim tawm los tig lub zog rau/tawm, ua haujlwm ntawm ib qho khoom lossis hloov roj teeb. Thiab "Hav!" lub thawv dawb thiab kuv nyiam cappuccino. Recycling yas yog qhov zoo rau ib puag ncig. Koj tuaj yeem siv lub thawv twg los xij uas koj nyiam uas txhua yam haum rau lossis txawm hla lub npov lossis qhob cij ua haujlwm. Kuv xav tau "tiav qhov project saib" ntawm tus nqi pheej yig. Kuv twv ib tus neeg tsim cov ntawv luam tawm 3D. Arduino ua si Paper Rock Scissors game nrog koj ntawm LCD, khaws cov qhab nia, koj tuaj yeem nkag nrog cov nyees khawm, thiab yog tias koj xaiv muaj qhov kev xaiv uas tso cai rau koj dag. Keeb kwm cov yam ntxwv dag tau sau rau lub hom phiaj debugging thiab thaum kuv ua tiav nrog nws kuv tawm tswv yim nws tawm. Tsuas yog kev lom zem kuv muab tso rov qab rau hauv.

Kauj ruam 2: Khob noom cookie-board

Mov ci-board
Mov ci-board
Mov ci
Mov ci

Kuv khob cij-boarded kuv circuits siv Arduino Uno tab sis thaum muab tag nrho ua ke siv Arduino Nano vim tias nws haum rau hauv lub thawv zoo dua. Yog li, koj tuaj yeem tsim qhov no nrog ib qho twg. Tab sis nco ntsoov hloov ob peb qhov chaw hauv IDE. Lub Nano tau teeb tsa rau sab nraum qab ntawm LCD siv Command Strips lossis ob-sided nplaum daim kab xev. Muab Arduino Nano nyob ib sab ntawm I2C piggyback board kom USB txuas yuav ntsej muag sab nrauv (mus rau sab xis ntawm LCD). Koj tuaj yeem siv 9v lossis 4x AA (uas muab rau koj 6v) lub thawv roj teeb nrog SPST swb hloov rau lub zog txuas sab hauv lub thawv kuj nrog Command Strips. Ua nws ob txoj hauv kev, Arduino muaj tus tswj hwm qhov ntsuas hluav taws xob uas coj nws mus rau 5 volts nws xav tau. Yog tias koj xav txog nws qhov kev ua si no tuaj yeem siv dua tshiab "feem ntau tuag 9v roj teeb" rau lub zog thiab ua haujlwm tau zoo. (Koj hloov cov roj teeb ntsuas hluav taws xob ob zaug hauv ib xyoos, puas yog?) Lwm cov khoom siv uas siv roj teeb 9v yuav hais tias nws tuag ntawm 6 - 8 volts; tab sis nws tsis tuag txog thaum nws "Arduino Tuag!"

Thaum tsim qhov phiaj xwm kuv siv 4 SPST laub khawm rau nkag mus, tab sis tsim kom tiav qhov kev ua si rau hauv lub thawv siv 5 SPST laub khawm xav yav tom ntej Kuv yuav sim ua qhov game uas xav tau khawm ntau dua. Tej zaum kev ua si tshawb nrhiav? Tus tiv thaiv hluav taws xob faib hluav taws xob rau cov nyees khawm tau teeb ua ke ntawm cov seem seem ntawm lub rooj sib tham proto uas tseem tuaj yeem teeb tsa nrog Command Strips.

Kauj ruam 3: Sib dhos

Los ua ke
Los ua ke
Los ua ke
Los ua ke
Los ua ke
Los ua ke

Sib dhos:

4 lub rooj sib txoos tseem ceeb yog LCD nrog xaiv I2C piggyback board, Arduino Nano, tus tiv thaiv thiab hloov pauv daisy txuas rau lub rooj sib tham sib txuas ua ke thiab lub roj teeb lub thawv nrog rau/tawm hloov.

Koj yuav tsum pib los ntawm qhob cij-boarding lub Circuit Court lossis nyuaj hlau proto board tom qab cov txheej txheem. Kuv nyiam khaws LCD lub ntsej muag hauv qab lub thawv kom tsis txhob khawb nws. Kuv siv lub taub hau ntawm tsuas yog ib sab ntawm Arduino uas muaj 5v txuas nws mus rau pawg thawj coj saib. Kuv tau ua tus choj nrog 3 lub taub hau (ntau ntau cov haujlwm ua haujlwm txuas) los ntawm Arduino mus rau lub rooj sib tham proto yog li lawv nteg tiaj rau sab nraum qab ntawm LCD nrog Cov kab hais kom ua lossis ob daim nplaum nplaum. Tab sis tiag tiag, cov laug cam tuaj yeem txuas nrog tsuas yog siv cov xov hlau los ntawm ib qho mus rau lwm qhov. Siv tus poj niam lub taub hau los txuas lub rooj sib tham proto rau LCD I2C. Proto board resistor ob txhais ceg tuaj yeem siv los ua 5 lub ntsiab lus txuas rau cov nyees khawm. Ob txhais ceg ntawm txhua lub pob mus rau Arduino tus pin A0. Txhua lub pob yuav xav tau 2 lub xov hlau txuas. Siv lub ntsuas Ohm los txiav txim seb khawm ob txhais ceg yuav siv li cas tab sis feem ntau koj tuaj yeem ua tsis tau nrog cov ceg uas tsis nyob ib sab (kab pheeb ntawm ib leeg).

Xaiv koj cov chaw rau koj Arduino hauv IDE. Rub tawm daim duab kos thiab thauj nws mus rau Arduino thiab sim / teeb meem tua.

Npaj txhij muab nws tso rau hauv ib lub thawv? Tshem daim ntawv lo rau cappuccino, ntxuav thiab qhuav kuv lub thawv. Ua tib zoo ntsuas thiab txiav tawm lub qhov hauv lub thawv rau LCD raws li koj tuaj yeem pom thiab nws tau teeb tsa nrog 3 dowels ntsia mus rau peb lub kaum ntse ntse LCD (2 mus rau hauv qab ntawm lub npov, 1 ze ntawm lub hau) tsuas yog ntev txaus kom ncav cuag rov qab ntawm lub thawv thiab khaws nws nyob rau hauv qhov chaw nrog kev sib txhuam. Lub qhov ntsia hlau ntawm LCD lub rooj zaum piggyback yuav nyob ze rau lub davhlau ya nyob twg, yog li kuv tso tseg. Siv rab riam Exacto txhawm rau txhawm rau qhov ntsuas qhov rau cov ntsia hlau hauv lub dowels kom lawv tsis txhob sib cais (ceev faj, tsis txhob plam thiab tua koj tus kheej, tuav dowels nrog pliers). Yuav tsum khoov / tsoo lub thawv me ntsis rau kev teeb tsa zaum kawg, tab sis nws snaps rov qab kom zoo. Lub qhov rau cov nyees khawm yog "drilled" los ntawm kev tso lawv (kos kab nrog ntug ncaj) thiab ua kom sov lub dav hlau nrog cov hlau txuas kom txog thaum lawv "yaj dhau" lub thawv. Tom qab ntawd tshem cov nyees khawm tom qab lawv txias thiab muab tshuaj txhuam rau ntawm 6 " - 9" CAT 5e xaim xaim lossis 18ga txog 22ga xaim rau cov nyees khawm. Nruab cov nyees khawm hlau-ua ntej rov qab rau hauv lawv lub qhov tom qab ntawd txuas rau lub resistor proto-board. Dot ntawm super kua nplaum, kua nplaum kub lossis txawm tias tsuas yog kev sib txhuam yuav ua rau cov nyees khawm nyob hauv qhov chaw. Ntawm ib qho tsim siv qee lub xov tooj cable txuas (cov voj liab hauv cov yas yas thaiv) los pab ua qhov kawg ntawm kev sib txuas yooj yim dua ntawm lub roj teeb lub thawv, tiv thaiv proto-board thiab LCD / Arduino sib dhos. Yog tias koj xav tau koj tuaj yeem siv cov laug thiab cov cua sov hloov pauv. Tom qab ntawd ua tib zoo thiab maj mam thawb tag nrho cov xaim thiab cov khoom siv rau hauv lub thawv thiab kaw lub hau. Koj puas tau teeb lub roj teeb thiab tso daim duab Arduino ua ntej ua txhua yam no? Koj tseem yuav xav tau lub tsev qiv ntawv rau 20x4 LCD zaub nrog lossis tsis muaj I2C (qhov twg koj xaiv) uas koj tuaj yeem rub tawm dawb ntawm Github. Fais fab nws, sim nws, thiab pom tias nws ua haujlwm. Tom qab ntawd kuv kho kuv daim duab nrog ncua ua ntu zus kom yooj yim nyeem, ntxiv qhov "ntsais ntsais cov nyhuv" thiab qee yam ntxiv nrog rau cov lus pom ntau. Sim muab tso rau Arduino kom USB tseem tuaj yeem txuas nrog thiab kos duab tshiab tso tawm. Siv daim ntawv ntws, tau kawg, thaum tsim cov duab kos. Koj yuav pom cov lus pom zoo piav qhia qhov twg txhua qhov thaiv ntawm daim ntawv qhia ntws.

Koj yuav pom tias cov nyees khawm nyob hauv kab / kab sib chaws uas tso cai rau koj siv ib qho Arduino tus pin nkag rau ntau lub khawm raws li koj nyiam. Lub voj voog ua haujlwm zoo li qhov faib hluav taws xob txhawm rau pub tus nqi rau tus lej sib piv hloov tus nqi nyeem los ntawm txhua lub khawm nias. Koj tuaj yeem siv tus lej saib xyuas txhawm rau txheeb xyuas koj li txiaj ntsig hauv Circuit Court raws li koj cov resistors thiab hloov qhov "lees paub qhov tseem ceeb" hauv koj daim duab.

Vam tias koj muaj kev lom zem tsim koj tus kheej! Yog tias koj ua ib lossis txawm tias ua qee qhov kev hloov ntawm qhov no thov qhia rau peb ntawm lwm tus. Ua tsaug rau koj nyeem.

Kauj ruam 4: Programming thiab Chaw

Programming thiab Chaw
Programming thiab Chaw
Programming thiab Chaw
Programming thiab Chaw

Tam sim no kom lom zem nrog IDE. Kuv vam tias koj tau haus qee cappuccino. Koj yuav xav tau nws los pab koj tsaug zog.

Tej zaum koj yuav pom tias koj yuav tsum teeb tsa qee lub tsev qiv ntawv. Koj yuav xav tau Wire.h Rau I2C, LCD.h rau LCD, LiquidCrystal_I2C.h rau I2C tswj LCD. Koj kuj tseem yuav tsum siv lo lus txib lcd.begin (20, 4) qhia rau Arduino koj siv 20 tus cim 4 kab LCD thiab tej zaum yuav muaj lwm qhov chaw.

Yog xav paub ntxiv txog kev txhim kho cov tsev qiv ntawv, saib:

Hauv Arduino IDE koj yuav pom tias koj yuav tsum teeb tsa koj lub rooj tsavxwm thiab chaw nres nkoj uas koj muaj nws txuas nrog. Qhov chaw nres nkoj tuaj yeem pom hauv koj lub computer tswj vaj huam sib luag/tus tswj lub cuab yeej/Universal Serial Bus controllers. Koj yuav tsum txiav txim siab seb Arduino koj tab tom siv. Kuv siv Arduino Nano tab sis Uno ua haujlwm rau qhov no ib yam. Xaiv koj qhov chaw ua tib zoo.

Koj yuav xav paub koj li I2C chaw nyob. Koj yuav tsum muaj peev xwm nyeem nws ncaj qha los ntawm pawg thawj coj dhia. Koj tseem tuaj yeem rub lub I2C scanner los ntawm Arduino.cc lossis tseem https://www.gammon.com.au/forum/?id=10896 thiab lwm qhov chaw.

Qee qhov nyob ib puag ncig ntawm qhov no koj yuav tsum muaj peev xwm thauj qhov haujlwm mus rau Arduino thiab sim ua haujlwm. Puas yog lub vijtsam LCD teeb? Koj puas nyeem tau cov cim? Ib zaug kuv tau tsim lub Circuit Court tom qab ntawd sim nws lub teeb pom kev rov qab tab sis cov cim nyeem tsis tau. Siv sijhawm teev (yog lawm, HOURS) sim teeb tsa thiab sib txuas sib txuas kom ntseeg tau tias nws tau ua tiav raug. Tso rau ob peb hnub. Rov qab los rau nws tom qab thiab paub qhov sib txawv resistor ntawm cov piggyback board tau teeb tsa yam tsawg kawg nkaus. Hloov nws thiab cov cim tau pom. Bang lub taub hau ntawm lub rooj. Lwm qhov laj thawj los tsoo koj lub taub hau ntawm lub rooj? Yog tias koj xav hloov lub roj teeb koj yuav xav tau kho qhov sib txawv resistor no dua. Thaum qhov no tshwm sim kuv txiav lub qhov me me nyob tom qab ntawm lub npov kom nkag tau.

Koj yuav xav tau teeb tsa koj tus kheej lub pob qhov tseem ceeb hauv txoj haujlwm no raws li cov neeg tawm tsam koj siv rau koj cov nyees khawm. Koj tuaj yeem siv qhov kev kos me me rau qhov ntawd thiab nco ntsoov qhib lub koos pij tawj saib. Khiav cov duab kos thiab nias txhua lub pob thiab sau txhua tus nqi. Tom qab ntawd kho cov duab kos kom pom koj lub pob qhov tseem ceeb. Tom qab ntawd rub tawm daim duab kho kom raug rau koj pawg thawj coj saib seb nws puas ua haujlwm.

Muaj ntau qhov sib txawv me me uas txhua tus yuav tsum raug thiab koj li yuav txawv dua li kuv li. Ua siab ntev thiab sim ua yam sib txawv yuav pab koj ua koj txoj haujlwm. Tseem nco qab tom qab koj teeb tsa koj li Arduino hloov pauv (Zoo li lub npe lub rooj tsavxwm, com 3, 5 lossis ib qho twg, tus txheej txheem thiab tus programmer [txhua tus hauv qab cov cuab yeej]) koj yuav muaj lawv txhua qhov teeb tsa raug tab sis nws tsis ua haujlwm vim tias koj xav tau rov pib dua. Tshem lub Arduino thiab ntsaws nws rov qab rau hauv koj lub computer. Tej zaum koj yuav tsum tau txuag thiab rov pib koj lub computer dua.

Tshaj tawm cov duab kos no, khiav tus saib xyuas, thawb cov nyees khawm thiab sau cov txiaj ntsig, tom qab ntawv hloov Daim Ntawv Pob Zeb Txiab kos duab hloov pauv kuv qhov kev cuam tshuam nrog koj li. Khiav Cov Ntawv Pob Zeb Txiab kos duab thiab saib seb nws puas ua haujlwm raug. Huag yog, koj puas tau teeb tsa koj cov nyees khawm tsis raug? Koj yuav tsum tau rov nruab lawv yog tias koj xav tau lawv nyob rau hauv ib qho kev xaj tshwj xeeb.

Muaj kev lom zem!

Kauj Ruam 5: Khawm Nyeem Sketch Yuav Pab Koj Nrhiav Koj Li Resister Qhov Tseem Ceeb los Kho Kom Haum Rau Hauv Daim Duab Sketch. Laub Txhua Khawm thiab Sau Koj Tus Kheej Tus Kheej kom nkag mus rau hauv Daim Duab Sketch

// khawm nyeem kab kos

void teeb tsa () {

// muab koj cov cai teeb tsa ntawm no, kom khiav ib zaug:

Serial.begin (9600);

}

void voj () {

// muab koj cov cai tseem ceeb ntawm no, kom rov ua dua:

koj buTTon; // Rau kev nyeem cov nyees khawm

buTTon = 0; // Rau kev nyeem cov nyees khawm

buTTon = analogRead (A0); // Hais kom siv los nyeem Cov Nyees khawm

ncua (100);

Serial.println (buTTon);

Kauj Ruam 6: Cov Npe Cov Npe thiab Cov Cuab Yeej uas Koj Yuav Tsum Muaj

Daim Ntawv Teev Npe Los Ntawm Amazon:

Arduino Uno lossis Arduino Nano

20x4 LCD zaub nrog lossis tsis muaj I2C

9v lossis 6v lub roj teeb lub thawv nrog SPST swb hloov (lossis tau txais lub swb hloov cais)

5x SPST laub khawm

1x Rub -up Resistor 1k - 5k

5x Resistors tsawg dua 1k, 200 - 500 Ohms yog qhov zoo

Lists Lists Lwm qhov chaw lossis khw muag khoom:

9v lossis 4x 1.5-volt roj teeb (9v xaiv tso cai rau koj siv roj teeb "feem ntau tuag")

Command Strips (siv pob ntim rov ua dua) lossis daim kab xev nplaum ob tog

Xov tooj cable splicers (xaiv tau tab sis ua kom yooj yim txuas cov xov hlau)

Ob peb ntiv tes ntawm 1/4 dowel

Cov ntoo me me ntsia hlau txhawm rau rub dowels rau LCD

Solder

Tshav Kub Kub rau 18 ga xov hlau

Scraps lossis Recycling Parts:

Ntim cappuccino lub raj mis sib tov sib xyaw (tsis yog txhua tus muaj lub tshuab luam ntawv 3D, muaj qee lub cappuccino thiab rov ua dua qee cov yas)

Txog 1 "x 2" Proto board seem txawm hais tias kuv tau siv protoboard los ntawm Amazon

Ntau qhov ntev ntawm 18ga txog 22ga xaim lossis Cat 5e cov tub ntxhais muaj zog

Cov Cuab Yeej Koj Yuav Tsum Tau:

Ntsia Hlau me me Philips

Cov me me tiaj tus ntsia hlau

Riam Exacto

Soldering hlau thiab solder

Hnyav plaub ntug txiab

Koob qhov ntswg pliers

Tus kav

Kauj Ruam 7: Qee Cov Lus Qhia Ntxiv thiab Daim Duab Sketch

Ua tsaug rau koj nyeem. Kuv paub tias nws muaj ntau. Nov yog kuv thawj Qhov Kev Xav Tau thiab qhov no ib leeg tau kawm me ntsis rau kuv. Saib rov qab kuv pom kuv hais lus nyob hauv qee qhov chaw thiab luv luv hauv lwm tus. Kuv yuav tsum tau tawg lub rooj sib txoos ntau dua rau hauv cov kauj ruam. Thiab txij li thaum kuv tsim txoj haujlwm no txog kaum ob zaug kom txog thaum nws raug cai qee cov duab yog los ntawm ib tus qauv lossis lwm tus. Kuv yuav tsum tau rov qab thiab thaij duab ntawm ib tus qauv xwb. Kuv kuj xav suav nrog cov vis dis aus lossis ob. Yog li yog, Kuv yuav rov qab los thiab kho cov khoom no. Tab sis tam sim no kuv muab tso rau hauv koj txhais tes. Kuv vam tias koj txaus siab tsim nws ntau npaum li kuv tau ua. Ua tsaug rau koj nyeem dua.

Pom zoo: