Cov txheej txheem:

QuizzPi, Raspberry Pi Trivia Game With Python: 7 Kauj Ruam (nrog Duab)
QuizzPi, Raspberry Pi Trivia Game With Python: 7 Kauj Ruam (nrog Duab)

Video: QuizzPi, Raspberry Pi Trivia Game With Python: 7 Kauj Ruam (nrog Duab)

Video: QuizzPi, Raspberry Pi Trivia Game With Python: 7 Kauj Ruam (nrog Duab)
Video: QuizzPi, a Raspberry Pi trivia game 2024, Hlis ntuj nqeg
Anonim
QuizzPi, Raspberry Pi Trivia Game With Python
QuizzPi, Raspberry Pi Trivia Game With Python
QuizzPi, Raspberry Pi Trivia Game With Python
QuizzPi, Raspberry Pi Trivia Game With Python

QuizzPi yog hom kev ua si tsis tseem ceeb arcade. QuizzPi yug los vim kuv xav tau muab kuv tus ntxhais ua kev lom zem. Nws yog 7 xyoo thiab nws twb xav tau kev siv thev naus laus zis tshiab, lub tswv yim yog los tsim qee yam uas yog kev lom zem thiab kev kawm.

Yuav tsum muaj ntawm txoj haujlwm:

  • Yooj yim rau siv
  • Portable
  • Yooj yim hloov kho cov teeb tsa cov lus nug thiab lus teb
  • Cov qhab nias siab

Ntau yam khoom yog teeb tsa. Koj tuaj yeem tsim koj tus kheej cov database ntawm cov lus nug/lus teb lossis koj tuaj yeem siv ib qho ntawm ntau lub server uas muab cov ntaub ntawv khaws cia, qhov twg koj txiav txim siab hom lus nug, nyuaj, … hloov kho kom tau txais cov lus nug tsis tseem ceeb los ntawm cov neeg rau zaub mov oline. Cov ntawv qhia no tau txais cov lus nug los ntawm cov lus nug sib koom thiab teb, Qhib Trivia Database. Kuv tau xaiv cov lus nug kev paub dav tab sis koj tuaj yeem xaiv cov yeeb yaj kiab, kis las lossis lus nug txog kev ntseeg.

Kuv thov txim rau kuv cov lus Askiv tsis zoo. Kuv yog neeg Mev tab sis kuv tau nyiam tsim cov lus qhia no ua lus Askiv yog li nws tuaj yeem mus txog rau ntau tus neeg.

Wb mus!

Kauj Ruam 1: Koj Xav Tau Qee Cov Khoom thiab Cov Cuab Yeej …

Koj Xav Tau Qee Cov Khoom thiab Cov Cuab Yeej …
Koj Xav Tau Qee Cov Khoom thiab Cov Cuab Yeej …

Koj muaj feem ntau ntawm cov khoom siv hauv tsev kom paub tseeb…

  • Raspberry Pi 2/3 nrog 8Gb lossis ntau daim npav SD (35 $)
  • Raspberry Pi 3.5inch LCD nrog rooj plaub (11 $). Saib (qhov no yog nyob ntawm yeem, koj tuaj yeem siv ib qho khoom uas koj muaj, koj tsuas yog yuav tsum hloov kho QuizzPi rooj plaub rau nws)
  • Roj teeb. Koj tuaj yeem siv lub txhab nyiaj lossis koj tuaj yeem siv lub roj teeb diy 18650 (5 $). Hauv kuv qhov xwm txheej kuv siv ib lub txhab nyiaj Aukey 5000mah (12 $). Saib
  • Plaub arcade nyees khawm. Kuv muaj cov no hauv tsev (3 $, 12 khawm rau 10 $). Saib
  • Ib qho rau/tawm hloov (0.25 $). Saib
  • Ob lub USB txuas (0.50 $)
  • Ib lub USB/micro USB cable
  • Ib tus hais lus pheej yig (xaiv tau) (0.25 $). Saib
  • Ib lub tshuab PAM8403 (xaiv tau) (0.80 $). Saib
  • Qee qhov xov hlau txuas cov khawm, txuas USB thiab qhib/tua hloov mus rau GPIO pins (1 $?)
  • Plaub lub hlau nplaum neodymium lossis koj tuaj yeem siv yam khoom twg los tau kaw lub qhov rooj tom qab. Saib
  • Plywood. Kuv siv 5mm plywood tab sis koj tuaj yeem siv txhua yam koj muaj hauv tsev (2 $)

Koj xav tau qee yam cuab yeej ib yam nkaus…

  • Cov Khoom Siv Hluav Taws Xob
  • Ntsia hlau tsav tsheb
  • Hotglue phom
  • 3D tshuab luam ntawv (yeem)

Wb mus!

Kauj Ruam 2: Cia Tsim Tus Qauv QuizzPi Txias …

Cia Tsim Tus Qauv QuizzPi Txias…
Cia Tsim Tus Qauv QuizzPi Txias…
Cia Tsim Tus Qauv QuizzPi Txias…
Cia Tsim Tus Qauv QuizzPi Txias…

Thawj qhov peb xav tau yog paub tias muaj pes tsawg qhov chaw peb xav tau suav nrog kho vajtse (Raspberry + screen + nyees khawm + roj teeb + xov hlau). Ua raws li cov ntu tau piav qhia hauv cov kauj ruam dhau los Kuv tau tsim 3D tsim ntawm rooj plaub uas siv online dawb 3D tus tsim qauv Tinkercad (Saib). Yog koj xav luam cov qauv 3D ntawm rooj plaub koj tuaj yeem rub nws los ntawm cov ntawv txuas nrog QuizzPi.stl

Lub sijhawm ntawd kuv yuav tsum txiav txim siab tias yuav luam tus qauv ntawm kuv lub tshuab luam ntawv 3D lossis ua nws tawm ntawm plywood. Kuv xav tias ua rau kuv tus ntxhais Kuv tuaj yeem siv sijhawm me ntsis ntxiv los ua cov plywood. Yog li kuv tau txais cov phiaj xwm los ntawm tus qauv 3D thiab txiav ntoo.

Cov kauj ruam tom ntej yog kub-nplaum cov ntu …

Kauj Ruam 3: Ua Plywood Case…

Ua Plywood Case…
Ua Plywood Case…
Ua Plywood Case…
Ua Plywood Case…
Ua Plywood Case…
Ua Plywood Case…
Ua Plywood Case…
Ua Plywood Case…

Thaum kuv tau txiav tag nrho cov plywood ntu ntawm cov phiaj xwm theem tom ntej yog kub-nplaum lawv. Hauv qee qhov koom nrog kuv muab kev txhawb ntxiv kom lub thawv muaj zog dua. Hauv lub bezel kuv kos nrog tus xaum tus qauv ntawm lub vijtsam LCD, thiab txiav tawm. Kuv ua plaub qhov rau cov ntsia hlau. Yog tias koj siv lub vijtsam sib txawv koj yuav tsum hloov kho qhov no.

Lub qhov rooj rov qab kaw nrog ob lub hlau nplaum txuas rau lub qhov rooj thiab ob lub hlau nplaum nplaum rau rooj plaub, yog li kuv zam kev siv hinges.

Cov ntaub ntawv QuizzPi tau ua tiav…

Kauj Ruam 4: Txuas GPIO Pins, Mounting Raspberry+LCD …

Txuas xov GPIO Pins, Mount Raspberry+LCD…
Txuas xov GPIO Pins, Mount Raspberry+LCD…
Txuas xov GPIO Pins, Mount Raspberry+LCD…
Txuas xov GPIO Pins, Mount Raspberry+LCD…
Txuas xov GPIO Pins, Mounting Raspberry+LCD…
Txuas xov GPIO Pins, Mounting Raspberry+LCD…

Peb yuav tsum txuas cov nyees khawm mus rau Raspberry Pi yog li nws tuaj yeem paub tias khawm raug thawb. Khawm tau txuas nrog GPIO pins. Peb xav tau plaub IN GPIO pins ntxiv rau ib tus Gnd GPIO tus pin. Kuv siv GPIO tus pin 31 (GPIO6), 33 (GPIO13), 35 (GPIO19), 37 (GPIO26) thiab 39 (Gnd) rau khawm liab, daj, ntsuab thiab xiav. Lub vijtsam no muaj SPI interface. Qhov no txhais tau tias nws txuas nrog GPIO lub txhab nyiaj, yog li ua ntej kuv tso cov xov hlau xaus rau hauv cov xwm txheej hauv cov nyees khawm thiab tom qab ntawd kuv txuas lub vijtsam LCD.

Cov kauj ruam tom ntej yog txhawm rau txhim kho Raspberry+LCD+rooj plaub mus rau lub bezel. Kuv siv cov ntaub ntawv Raspberry Pi tus kheej ntsia hlau.

QuizzPi tau teeb tsa…

Kauj Ruam 5: Roj teeb, Khawm, Hloov thiab USB Txuas …

Roj teeb, Khawm, Hloov thiab USB Txuas …
Roj teeb, Khawm, Hloov thiab USB Txuas …
Roj teeb, Khawm, Hloov thiab USB Txuas …
Roj teeb, Khawm, Hloov thiab USB Txuas …
Roj teeb, Khawm, Hloov thiab USB Txuas …
Roj teeb, Khawm, Hloov thiab USB Txuas …

Kuv siv Tinkercad dua los tsim daim clip los tuav lub hwj chim rau hauv rooj plaub. Kuv tau luam daim clip nrog kuv lub tshuab luam ntawv 3D thiab koom nrog rooj plaub nrog kub yaj yaj phom. Kuv muab cov ntaub ntawv.stl ntawm tus qauv hauv qab no. Yog tias tsis muaj lub tshuab luam ntawv 3D koj tuaj yeem koom nrog lub txhab nyiaj hluav taws xob nrog daim kab xev velcro.

Cov kauj ruam tom ntej yog txhawm rau txuas rau/tawm hloov ntawm lub txhab nyiaj thiab Raspberry Pi. Kuv tau siv USB cable thiab kuv txiav tsuas yog lub xaim hluav taws xob, tom qab ntawd kuv tau txuas ib lub xov hlau txuas rau ib tus pin ntawm qhov qhib/tua thiab lwm lub xov hlau txuas mus rau lwm tus pin ntawm qhov qhib/tua. Yog li thaum qhov kev hloov pauv hauv lub zog tsis dhau los ntawm swtich thiab Raspberry tau tawm thiab thaum lub zog hloov mus los ntawm swtich thiab Raspberry tau qhib.

Thaum lub txhab nyiaj hluav taws xob tso tawm yog qhov teeb meem tshem nws tawm ntawm rooj plaub kom them nws, yog li kuv tsis xav tshem nws txhua lub sijhawm kom them. Qhov teeb meem yog lub txhab nyiaj hluav taws xob them nqi chaw nres nkoj yog USC hom C, thiab kuv tsuas muaj lub cable ntawm lub txhab nyiaj hluav taws xob. Yog li kuv tau siv ob tus poj niam txuas USB thiab muab tso rau hauv rooj plaub. Qhov txuas sab hauv los txuas rau lub txhab nyiaj fais fab cable, thiab sab nraud txuas los txuas lub USB fais fab cable.

Txhawm rau tso cov nyees khawm thiab thaiv lawv tau yooj yim. Cov nyees khawm muaj 2 tus pin, ib tus pin ntawm txhua lub khawm txuas rau ib qho txuas uas txuas mus rau hauv av GPIO tus pin, thiab lwm tus pin ntawm lub pob txuas rau nws cov GPIO tus pin ntawm cov txiv pos. Daim duab kab hluav taws xob tau qhia hauv daim duab txuas nrog.

Lub kaw lus suab yog nyob hauv PAM8403, lub suab nrov pheej yig. Nws yog qhov tsim nyog vim tias lub suab tau los ntawm lub jack ntawm Raspberry Pi tsis muaj zog heev los ua tus hais lus ua haujlwm. Koj yuav tsum tau siv nws nrog 5v lossis ntau dua. Hauv cov duab txuas nrog koj tuaj yeem pom yuav ua li cas xaim lub suab nrov thiab tus hais lus. Peb xav tau tus txiv neej 3.5mm nkaus los txuas rau Rapberry lub suab/yees duab nkaus. Kuv muab 3 lub xov hlau txuas rau lub jack: suab, yees duab thiab hauv av. Daim duab txuas nrog qhia pom tus pin yog txhua tus. Tom qab ntawd kuv tau xaim xov hlau mus rau On/Off hloov rau lub zog los ntawm, thiab lwm lub xaim rau hauv av xaim los ntawm lub txhab nyiaj fais fab cable. Tom qab ntawd kuv txuas cov xov hlau los ntawm tus hais lus mus rau qhov tso tawm ntawm lub suab nrov. Ib qho yooj yim yog faib cov suab kaw lus hauv rooj plaub. Koj tuaj yeem pom hauv cov duab.

QuizzPi tau teeb tsa, hauv daim duab kawg peb tseem tuaj yeem pom cov xaum cim ntawm ntoo, tab sis nws yog lub sijhawm software … cia peb mus tsim lub cav me me xeem ntawv …

Kauj Ruam 6: Rasbian Duab thiab Ua Haujlwm Lub Tshuab Ntsuam Xyuas …

Rasbian Duab thiab Ua Haujlwm Lub Tshuab Ntsuam Xyuas…
Rasbian Duab thiab Ua Haujlwm Lub Tshuab Ntsuam Xyuas…
Rasbian Duab thiab Ua Haujlwm Lub Tshuab Ntsuam Xyuas…
Rasbian Duab thiab Ua Haujlwm Lub Tshuab Ntsuam Xyuas…
Rasbian Duab thiab Ua Haujlwm Lub Tshuab Ntsuam Xyuas…
Rasbian Duab thiab Ua Haujlwm Lub Tshuab Ntsuam Xyuas…
Rasbian Duab thiab Ua Haujlwm Lub Tshuab Ntsuam Xyuas…
Rasbian Duab thiab Ua Haujlwm Lub Tshuab Ntsuam Xyuas…

Peb nias lub hwj huam khawm. Tsis muaj dab tsi tshwm sim. Au kuv tus Vajtswv! Nws tsis ua haujlwm! Dab tsi yuav tsis raug? Puas muaj cable tsis txuas? Tsis txhob txhawj xeeb, peb yuav tsum teeb tsa daim duab ntawm SD daim npav …

Lub cav ntsuas tau sau rau hauv Python 3, yog li peb xav tau Raspbian duab nrog Python compiler tau teeb tsa. Txij ntawm no peb yuav tsum coj mus rau hauv tus account hom tshuaj ntsuam uas peb tau teeb tsa. Kuv lub vijtsam yog SPI interface, thiab tus muag khoom muab cov duab Raspbian nrog txhua lub vijtsam tsav tsheb teeb tsa. Qhov Raspbian version no muaj Python engine ib yam nkaus. Koj tuaj yeem rub daim duab no hauv qhov txuas no.

Yog tias koj muaj lub vijtsam HDMI lossis RCA koj tuaj yeem rub tawm Raspbian duab kawg nyob rau hauv qhov chaw raspberrypi.org. Nco ntsoov: koj xav tau Desktop Rasbian version, yog li zam kom rub tau Lite Raspbian duab. Cov duab no suav nrog Python compiler.

Txhawm rau teeb tsa daim duab mus rau SD daim npav peb tuaj yeem siv ib qho kev thov. Kuv siv Win32diskimager. Tom qab ntawd peb ntxig daim npav SD rau hauv Raspberry thiab nias rau/tawm hloov. Nws ua haujlwm! Tam sim no peb yuav tsum tsim qhov program Python nrog lub cav quizz.

Cov kauj ruam tom ntej yog rub cov ntaub ntawv ntawm lub cav xeem ntawv. Kuv tau txuas qhov chaws hauv cov ntaub ntawv QuizzPi.zip. Rub tawm lub hauv paus thiab tsim daim nplaub tshev hauv Raspberry Pi:

# mkdir/tsev/pi/QuizzPi

thiab unzip cov ntawv rub tawm rau hauv daim nplaub tshev no.

QuizzPi.zip muaj cov ntawv no:

  • QuizzPi.py - nws muaj cov cai
  • MP3 cov ntaub ntawv suab - koj tuaj yeem hloov kho tus kheej
  • losmejores.txt - nws muaj cov qhab nia siab cov lus, koj tuaj yeem tshem nws kom pib lub rooj
  • Cov lus qhia.txt

Kuv yuav tsis muab cov lus piav qhia ntxaws txog qhov kuv tau teeb tsa lub cav code hauv Python vim tias nws nyuaj rau tib neeg yam tsis muaj kev paub txog lub cajmeem. Lawv tsuas yog xav khaws cov ntaub ntawv hauv Raspberry. Cov tib neeg nrog kev paub txog kev paub yuav muaj peev xwm hloov kho nws yam tsis muaj kev piav qhia;)

Cov lus nug thiab lus teb yog los ntawm Cov Lus Nug & Cov Lus Teb koom ua ke hu ua Qhib Trivia Database, koj tuaj yeem pom ntawm no. Koj tuaj yeem hloov pauv qeb thiab nyuaj ntawm cov lus nug hloov kab hauv cov ntawv QuizzPi.py:

#Cargo desde URLurl = 'https://opentdb.com/api.php?amount=10&type=multiple'

hloov nrog qhov url tau los ntawm api configurator

Kuv tsim cov ntxaij vab tshaus game hauv Photoshop, koj tuaj yeem hloov kho lawv. Koj tsuas yog yuav tsum khaws qee qhov chaw dawb hauv cov lus nug screen, hauv cov txiaj ntsig tshuaj ntsuam thiab cov qhab nias siab vim tias lub cav game sau rau lawv.

Koj tuaj yeem tsim tus kheej lub suab ntawm qhov kev ua si ib yam. Koj tsuas yog yuav tsum hloov pauv.mp3 cov ntaub ntawv los ntawm lwm tus uas koj xav tau, koj yuav tsum khaws cov npe qub. Koj tuaj yeem tau txais ntau lub suab los ntawm cov chaw khaws ntaub ntawv online, Kuv tau txais cov mines los ntawm Free Sound Effects.

Tam sim no koj yuav tsum hloov kho koj tus Raspbian kom ua tiav QuizzPi. Koj tuaj yeem nyeem kab ntawv no uas piav qhia yuav ua li cas:

Peb tau ua tiav !!!

Kauj Ruam 7: Qhia tawm…

Image
Image

Txhawm rau ua kom tiav cov lus qhia no koj tuaj yeem pom daim vis dis aus no. Koj tuaj yeem pom nws siv tau yooj yim thiab nyuaj ntawm cov lus nug nyob ntawm koj …

Kho kom raug: video hloov tshiab tam sim no nrog lub suab!

Kev sib tw Microcontroller
Kev sib tw Microcontroller

Khiav Tawm Hauv Kev Sib Tw Microcontroller

Pom zoo: