Cov txheej txheem:

TicTacToe Khoos Phis Tawj Siv RaspberryPi: 4 Cov Kauj Ruam
TicTacToe Khoos Phis Tawj Siv RaspberryPi: 4 Cov Kauj Ruam

Video: TicTacToe Khoos Phis Tawj Siv RaspberryPi: 4 Cov Kauj Ruam

Video: TicTacToe Khoos Phis Tawj Siv RaspberryPi: 4 Cov Kauj Ruam
Video: Google Colab - Working with Julia! 2024, Kaum ib hlis
Anonim
TicTacToe Khoos Phis Tawj Siv RaspberryPi
TicTacToe Khoos Phis Tawj Siv RaspberryPi
TicTacToe Khoos Phis Tawj Siv RaspberryPi
TicTacToe Khoos Phis Tawj Siv RaspberryPi
TicTacToe Khoos Phis Tawj Siv RaspberryPi
TicTacToe Khoos Phis Tawj Siv RaspberryPi

Txoj haujlwm no lub hom phiaj ntawm kev tsim qauv sib tham TicTacToe siv ob lub xim sib txawv LEDs qhia txog ob tus neeg siv siv raspberry pi. Lub tswv yim ntawm no yog txhawm rau ua qhov no ntawm qhov loj dua ntawm txoj kev taug - xav txog kab sib chaws ntawm 3x3 ib nrab ntiaj teb (zoo li cov uas tau hais los saum no) nyam ntawm phab ntsa uas nias ib qho pib qhov kev ua si (thiab cov xim tshwj xeeb LED tig rau). Qhov no tuaj yeem ua tiav hauv txoj kev ib sab ntawm cov tuav, pub noj lossis lwm qhov chaw uas tib neeg yuav tsum tau ua kab thiab tos - yog li ua rau thaj tsam yog thaj chaw sib tham uas tib neeg nyiam thaum lawv tos.

Khoom siv

Rau tus qauv - Kuv siv cov khoom muaj rau kuv:

  1. Raspberry Pi 3 Qauv B+ nrog raspbian teeb tsa ntawm SD daim npav
  2. Momentary Push Button - 9x
  3. LEDs - 9x Ntsuab, 9x Liab
  4. Cov qhob cij
  5. Cov xov hlau- Poj niam rau Poj niam, cov xov tooj tooj liab tsis tu ncua uas feem ntau tuaj nrog cov khoom siv dev- 22 guage insulated tooj liab hlau (zoo li qhov no (tsis muaj kev koom tes nrog tus muag khoom))- (https://www.amazon.com/Elenco-Hook-Up- Colors-dispenser-WK-106/dp/B008L3QJAS/ref = sr_1_1? Keywords = tooj liab+xov hlau+elenco & qid = 1568868843 & s = qhov rooj & sr = 8-1)
  6. 220 ohm resistors - 9x

Kauj Ruam 1: Teeb lub Breadboard Nrog 18 LEDs

Teeb lub Breadboard Nrog 18 LEDs
Teeb lub Breadboard Nrog 18 LEDs
Teeb lub Breadboard Nrog 18 LEDs
Teeb lub Breadboard Nrog 18 LEDs
Teeb lub Breadboard Nrog 18 LEDs
Teeb lub Breadboard Nrog 18 LEDs

Ua ntej, teeb tsa lub khob cij hauv kab sib chaws ntawm 3x3 nrog ob lub LED sib txawv ntawm ib sab raws li pom hauv daim duab saum toj no. Peb yuav tsav 18 LEDs siv tsuas yog 5 tus pin (hu ua tswj pins hauv qab) los ntawm raspberry pi. Qhov no ua tiav siv charlieplexing uas tau piav qhia zoo nkauj hauv cov lus qhia no (https://www.instructables.com/id/Charlieplexing-wi…). Saib xyuas kuv tab tom siv lub raj mis lub hau raws li qhia hauv cov duab saum toj no los npog kuv cov nyees khawm ntawm no kom haum tus qauv.

1. Ua ntej tso cov khub LED (thiab lawv qhov sib thooj sib thooj) XWB (ib qho liab lwm yam ntsuab lossis xim twg los xij uas koj xaiv) hauv qhov sib txawv ntawm qhov sib thooj hla tib kab hauv daim ntawv qhia zaub mov (saib daim duab saum toj no nrog pom hauv 1 khub). Ua kom ntseeg tau tias koj khaws tib ntu, piv txwv li sab saum toj yog ntsuab thiab hauv qab ib qho yog liab rau TXHUA LED khub.

2. Tom qab ntawv xaim cov LEDs (NCO TSEG: txhua lub xov hlau tswj mus rau LED khub ntawm 220 ohm resistor) siv cov lus qhia saum toj no - nws cov ncauj lus kom ntxaws nrog cov lus qhia txuas xov zoo, tsuas yog nco ntsoov koj tau tsim kab sib chaws nrog LEDs 0 thiab 1 ntawm sab saum toj sab laug thiab LEDs 16 thiab 17 nyob hauv qab txoj cai. (Tus lej LEDs pab nrog teeb tsa lub cev thiab kev ua haujlwm tom qab). LOSSIS ua raws cov xov hlau nyob hauv daim duab thib 2 kom pom tias kuv xaim cov LEDs li cas - saib cov kab xim hauv qab no ntws los ntawm kab saum toj mus rau kab hauv qab:

  1. Cov Hlau Dub (Pin 6 hauv av los ntawm pi) nyob rau saum toj kawg nkaus mus rau tag nrho txoj kev tsheb nqaj hlau - Kuv pub cov xaim no rau txhua ntawm 9 khawm
  2. Txiv kab ntxwv Hlau (Pin 7 - tswj tus pin1 los ntawm pi) hauv txoj kev tsheb nqaj hlau thib 2 saum LED 3 mus rau tag nrho txoj kev tsheb ciav hlau dua (-ive rail)
  3. Grey Hlau (Pin 11 - tswj tus pin2 los ntawm pi) hauv txoj kev tsheb nqaj hlau thib 2 saum toj no LED 3 mus rau tag nrho txoj kev tsheb nqaj hlau ib yam (+ive rail)
  4. Cov Hluav Taws Xob Hluav Taws Xob (Pin 12 - tswj tus pin3 los ntawm pi) hauv txoj kev tsheb nqaj hlau thib 3 saum LED 6 mus rau tag nrho txoj kev tsheb nqaj hlau (-ive rail)
  5. Xiav Hlau (Pin 13 - tswj tus pin4 los ntawm pi) hauv txoj kev tsheb nqaj hlau thib 3 saum LED 6 mus rau tag nrho txoj kev tsheb nqaj hlau (+ive rail)
  6. Ntsuab Hlau (Pin 15 - tswj tus pin5 los ntawm pi) hauv txoj kab 4 hauv qab LED 6 mus rau tag nrho txoj kev tsheb nqaj hlau (-ive rail)

Cov xov hlau yog xim xim yog li yuav tsum muaj peev xwm ua raws nrog - thov xyuas kom meej qhov sib txawv ntawm LEDs tau teeb tsa kom raug lwm qhov nws yuav tsis ua haujlwm !!

Kauj Ruam 2: Ntxiv 9 Nthuav Ib Sab ntawm LEDs

Ntxiv 9 Khawm Ib Sab ntawm cov LEDs
Ntxiv 9 Khawm Ib Sab ntawm cov LEDs
Ntxiv 9 Khawm Ib Sab ntawm cov LEDs
Ntxiv 9 Khawm Ib Sab ntawm cov LEDs

Ib sab ntawm txhua khub ntawm LEDs, ntxiv lub pob nyem tam sim no nrog ib txhais ceg sab hauv kab hauv av dub kab thiab lwm qhov rau hauv kab nrog xaim los ntawm raspberry pi. CEEB TOOM - Nws yog qhov zoo tshaj plaws los teeb tsa cov xov hlau txawm tias ua ntej muab cov nyees khawm tso rau hauv raws li qhia hauv daim duab hauv qib 1 yam tsis muaj khawm. Nws yuav yog qhov zoo tshaj plaws los teeb tsa cov xov hlau hauv av rau txhua 9 lub pob thiab tom qab ntawd teeb 9 lub xov hlau mus rau/los ntawm pi (tsis txhob txhawj xeeb txog dab tsi tus pin cov xov hlau tau los ntawm txij li koj feem ntau yuav tsis tau txuas cov xov hlau no rau pi tsis tau - yog li ua tib zoo ntxiv 9 xaim rau 9 khawm uas coj cov neeg siv nkag mus rau pi) raws li qhia hauv cov duab saum toj no.

Kauj Ruam 3: Txuas Cov Hlau Los Ntawm Breadboard mus rau Pi

Txuas Cov Hluav Taws Xob Los ntawm Breadboard mus rau Pi
Txuas Cov Hluav Taws Xob Los ntawm Breadboard mus rau Pi

Hauv 2 kauj ruam kawg peb tau txuas rau lub khob cij nrog LEDs thiab cov nyees khawm thiab lawv cov xov sib xws. Tam sim no peb txuas cov xov hlau no mus rau pi.

Raws li tau hais tseg hauv kauj ruam 1 - peb txuas 5 lub xov hlau tswj thiab xaim av dub rau LEDs rau tus pin xws li:

  1. Dub Hlau (Hauv av hlau) (Pin 6)
  2. Txiv kab ntxwv Hlau (Pin 7)
  3. Grey Hlau (Pin 11)
  4. Ntshav Hlau (Pin 12)
  5. Xiav Hlau (Pin 13)
  6. Ntsuab Hlau (Pin 15)

Tam sim no peb txuas 9 xov los ntawm 9 khawm mus rau pi. Nws yog qhov zoo tshaj los ua qhov sib tw sib tw ntawm 3 lub nyees khawm ua ke kom yooj yim rau kev tswj hwm xws li:

  • khawm 0 (kab = 0, kab lus = 0) - xaim liab (sab saum toj sab laug) - Pin 29
  • khawm 1 (kab = 0, kab ntawv = 1) - grey hlau - Tus lej 31
  • khawm 2 (kab = 0, kab ntawv = 2) - txiv kab ntxwv hlau - Pin 32
  • khawm 3 (kab = 1, kab lus = 0) - kab hlau daj - Pin 33
  • khawm 4 (kab = 1, kab lus = 1) - grey hlau - Tus Pin 35
  • khawm 5 (kab = 1, kab lus = 2) - txiv kab ntxwv hlau - Pin 36
  • khawm 6 (kab = 2, kab lus = 0) - xaim daj - Pin 37
  • khawm 7 (kab = 2, kab ntawv = 1) - grey hlau - Tus pin 38
  • khawm 8 (kab = 2, kab lus = 2) - xaim dub - Pin 40

Thaum txhua qhov kev sib txuas tau ua tiav peb tau npaj siab xa cov cai !!

Kauj ruam 4: Upload Code

Thaum txhua qhov kev sib txuas tau ua tiav, peb tau npaj txhij xa cov cai. Piv txwv tias koj tau txuas nrog pi ntawm rdp LOSSIS VNC - thov khaws cov ntaub ntawv hauv qab no ntawm pi (hauv tib lub nplaub tshev) thiab khiav FinalVersion.py cov ntaub ntawv los ntawm lub dav hlau LOS YOG ntawm thonny. Kuj xyuas kom koj muaj koj tus neeg hais lus txuas nrog pi (hais lus bluetooth yuav ua tau ib yam).

Yog tias koj tau nyam ntawm ib qho twg thov qhia rau kuv paub thiab kuv yuav ua qhov zoo tshaj plaws los pab koj !!

PS: Nov yog thawj qhov kuv tau qhia, yog li qhia rau kuv paub tias kuv tau ua li cas !!: AW

Pom zoo: