Cov txheej txheem:

Digital Chess - Taug qab Koj Cov Chess Game Online: 5 Cov Kauj Ruam
Digital Chess - Taug qab Koj Cov Chess Game Online: 5 Cov Kauj Ruam

Video: Digital Chess - Taug qab Koj Cov Chess Game Online: 5 Cov Kauj Ruam

Video: Digital Chess - Taug qab Koj Cov Chess Game Online: 5 Cov Kauj Ruam
Video: Mus yuav khoom zoo los siv tau. 2024, Kaum ib hlis
Anonim
Digital Chess - Taug qab Koj Cov Chess Game Online
Digital Chess - Taug qab Koj Cov Chess Game Online

Kuv tau ua si ntau yam chess txij li thaum kuv tseem hluas, thiab txij li lub vev xaib muaj ntau lub vev xaib los ua si chess ntawm cov khoos phis tawj lossis cov neeg sib tw nyob, Kuv ib txwm tsis tau pom lub vev xaib uas taug qab koj cov game chess uas koj ua si hauv lub neej tiag tiag. Yog li nrog txoj haujlwm no kuv vam tias yuav paub qhov ntawd!

Kuv vam tias:

  • Muaj peev xwm taug qab qhov kev txav ntawm daim chess
  • Pom qee tus thawj coj hais txog kev ua si yav dhau los.
  • Taug qab lub sijhawm thiab ua si nrawm zoo li kev ua si zoo.

Nws yog txoj haujlwm nyuaj heev txij li yog ua tiav nws yuav xav tau 64 lub teeb pom kev zoo thiab 8 daim ntawv los nyeem. Uas twb yog txoj haujlwm tseem ceeb thiab peb tsis suav nrog ib qho ntawm lwm yam khoom siv.

Kuv lub tsev kawm qib siab tau muab cov npe loj rau peb ua:

  1. Tsim ib qho schematic rau peb qhov project
  2. Tsim cov ntaub ntawv khaws cia thiab tau txais cov ntaub ntawv.
  3. Tsim lub vev xaib siv Adobe XD
  4. Rov tsim lub vev xaib no nrog CSS thiab HTML
  5. Nyeem cov sensors nrog nab hab sej
  6. Qhia cov ntaub ntawv ntsuas ntawm lub vev xaib siv lub hwj.

Hauv cov lus qhia no kuv yuav coj koj mus rau kuv txoj kev taug, thiab txhua yam teeb meem thiab lub sijhawm ntawm txoj kev cawm seej kuv tau hla dhau ob peb lub lis piam dhau los.

Kauj Ruam 1: Cov Khoom Siv/Cov Cuab Yeej

Cov khoom siv, khoom siv thiab cov cuab yeej yog thawj kauj ruam rau txoj haujlwm tiav!

Cov Cuab Yeej:

  • Soldering Hlau
  • Soldering Tin
  • Pliers
  • Drilling tshuab
  • Daim kab xev

Khoom siv:

  • Raspberry Pi nrog daim npav micro SD (4GB yuav tsum txaus)
  • Rasberry Pi T-cobbler
  • Chess Board nrog daim
  • 7 ntu zaub (TM 1637)
  • 2 Kov sensors (TTP223B)
  • RFID nyeem ntawv nrog daim npav (MFRC522)
  • MCP3008 (Nyob ntawm seb koj xav mus deb npaum li cas, rau txhua MCP koj tuaj yeem nyeem 8 Chess coordinates)
  • Lub Teeb Ntsuas Tus Ntsuj Plig hom 5288 (8 rau txhua MCP koj muaj)
  • Headers (Txiv neej rau txiv neej thiab Poj niam rau txiv neej)

Yog tias koj xav yuav txhua yam, tus nqi kwv yees yuav tsum yog nyob ib ncig 125 euros suav nrog tus nqi thauj khoom (Cov khoom siv nkaus xwb)!

Muaj cov ntawv Excel txuas nrog txuas thiab tus nqi rau txhua yam koj xav tau!

Kauj ruam 2: Schematics thiab Npaj

Schematics thiab Npaj!
Schematics thiab Npaj!
Schematics thiab Npaj!
Schematics thiab Npaj!

Cov kauj ruam tom ntej hauv txoj haujlwm no yog los tsim cov phiaj xwm. Kuv tau ua 2: Ib qho ntawm lub khob cij thiab ib qho khoom siv hluav taws xob. Peb yuav xav tau cov txheej txheem no txhawm rau ua kom txhua yam huv si thiab xyuas kom peb tsis txuas cov khoom uas tsis tsim nyog!

Kuv siv qhov program hu ua "Fritzing" los tsim cov lej no yog tias leej twg xav tau.

Xim Xim:

  • Liab = fais fab mov
  • Ntsuab = kev sib txuas
  • Xiav = av

Raspberry Pi kev sib txuas:

  • 3V3 => VC kab ntawm lub khob cij, txhawb txhua yam
  • 5V => VCC ntawm 7 ntu tso saib
  • GND:

    • Av rau ntawm daim ntawv qhia zaub mov
    • Hauv av ntawm 7 ntu tso saib
  • GPIO4 => Clock Xaiv tus pin ntawm MCP3008
  • GPIO10 => MOSI tus pin ntawm MCP3008
  • GPIO9 => MISO tus pin ntawm MCP3008
  • GPIO11 => CLK tus pin ntawm MCP3008
  • GPIO7 => SDA tus pin ntawm MFRC522
  • GPIO19 => DIG tus pin ntawm thawj Touch sensor
  • GPIO26 => DIG tus pin ntawm Kov sensor thib ob
  • GPIO20 => CLK tus pin ntawm xya ntu tso saib
  • GPIO21 = DIO tus pin ntawm ntu ntu xya

Ob peb sau ntawv ntawm schematics:

  • Cov txheej txheem no tsuas muaj 1 MCP, qhov no txhais tau tias tsuas yog 8 qhov kev tswj hwm thiaj tuaj yeem nyeem tau tag nrho.
  • Kuv yuav siv GPIO pins raws li kuv Chip Xaiv. Txij li tsuas yog 2 Chip xaiv tus pin muaj nyob nrog qhov muaj peev xwm 8 MCP's.
  • Qhov 7 ntu qhia yog ib tus kws qhia tawm tswv yim, tsuas yog 4 lub xovtooj xav tau vim nws ua haujlwm ntawm nws tus kheej raws tu qauv.
  • Cov neeg tawm tsam ntawm tus lej digital ntawm tus kov lub ntsej muag tsis xav tau tag nrho, tab sis tau qhia tawm.

Piav txog cov khoom siv:

  • MCP nrog lub teeb pom kev zoo:

    • MCP3008 yog 8 channel 10 ntsis ADC:

      • MCP3008 yuav nyeem lub teeb pom kev zoo 'tus nqi sib piv, tus nqi no nyob ntawm qhov pom ntawm lub teeb tam sim no ci ntawm lub ntsuas.
      • Hauv kuv tus nab npawb nab npawb kuv yuav tau txais tus nqi sib piv thiab hloov nws mus rau 1 lossis 0
  • Kov sensors:

    Ua haujlwm zoo li lub pob, kuv siv chav kawm rau qhov no nrog txoj kev hu rov qab. Ntau ntxiv txog qhov no tom qab

    RFID nyeem ntawv (MFRC 522):

    • Siv cov txheej txheem tshwj xeeb (SPI) nrog pob teeb tsa.
    • Tsis nyuaj rau code nrog pob teeb tsa
    • Nyeem tag thiab xa tus nqi ntawm daim ntawv
    • Koj kuj tseem tuaj yeem sau tus nqi rau ib daim ntawv, yog li tsis txhob rov qab tus lej hexadecimal, nws rov qab lub npe piv txwv

    7 Ntu (TM1637)

    • Kuj tseem siv pob teeb tsa kom yooj yim coding
    • Tsim qhov sib txawv nrog tus lej sib faib, tom qab ntawd faib nws ua 4 tus cim thiab qhia cov cim ntawd

Kauj ruam 3: SQL Database

SQL Cov Ntaub Ntawv
SQL Cov Ntaub Ntawv

Cov kauj ruam thib peb ntawm txoj haujlwm no yog tsim 3NF qhov qub SQL database!

Peb yuav xav tau qhov no rau:

  • Ntxig cov ntaub ntawv
  • Tau txais cov ntaub ntawv thiab qhia nws ntawm peb lub vev xaib
  • Muaj peev xwm pom qhov tseeb pes tsawg teev tau dhau los hauv qhov kev ua si ntawm chess tam sim no!

Cov ntawv piav qhia:

  • Kev ua si

    • Cov kab ntawv no leej twg yeej qee qhov kev ua si thiab thaum twg qhov kev ua si tau ua si
    • Thawj qhov tseem ceeb ntawm no yog GameID
    • Hnub tim muaj tus qauv tus nqi ntawm hnub tam sim no
    • Tus yeej thiab tus qhab nia yuav raug ntxiv tom qab, tom qab qhov kev ua si tiav!
  • Players (Spelers hauv Dutch)

    • Cov no tau muab tso rau ntawm tus kheej, tab sis kuj tseem tuaj yeem tso nrog siv daim npav RFID.
    • Sau lub npe rau koj daim npav, tom qab ntawv nyeem daim npav thiab ntxig lub npe rau hauv cov lus no
    • Nws tseem taug qab cov ntaub ntawv yeej / poob ntawm txhua tus neeg ua si, kom pom hauv lub vev xaib
  • Historiek (Keeb Kwm)

    • Nov yog tig keeb kwm
    • thaum daim chess txav mus, nws yuav raug hloov kho tshiab ntawm no
    • Nws muaj 3 tus yuam sij txawv teb chaws, neeg uas ua ntawv, game thiab chesspiece
    • Hnub Nyeem Ntawv (InleesDatum) yog hnub uas lub ntsuas tau nyeem
    • ReadTime zoo ib yam li ReadDate tab sis nrog lub sijhawm
    • LocationID (LocatieID) yog lub npe rau kev sib koom tes uas nws tau nyob. piv txwv li "a3"
  • Chess Pieces (Schaakstukken hauv Dutch)

    • Txhua daim chess muaj tus ID, pab pawg, lub npe thiab tus xwm txheej
    • Pab neeg no yog 1 lossis 2, dub lossis dawb;
    • Lub npe ntawm daim ntawv puas yuav yog "Pawn 1"
    • Qhov xwm txheej txhais tau tias daim ntawv tseem muaj sia lossis tuag!

Kauj ruam 4: Kho vajtse

Kho vajtse
Kho vajtse
Kho vajtse
Kho vajtse
Kho vajtse
Kho vajtse

Tam sim no uas peb tau txais txhua daim uas raug nyob hauv qhov chaw, peb tuaj yeem pib tsim qee yam!

Cia peb faib ntu no rau hauv cov theem hauv qab nws yuav yooj yim piav qhia:

  • Kauj Ruam 1: Koj xav laum lub qhov rau txhua qhov kev sib koom tes ntawm koj lub chessboard raws li pom hauv thawj daim duab, tseem yuav laum lub qhov uas koj xav tso lub ntsuas qhov kov, RFID nyeem ntawv thiab 7 ntu tso saib.

    Tsis txhob hnov qab tho qee qhov ntawm sab ntawm lub rooj tsavxwm, cov no yog rau cov xov hlau ntawm cov khoom sib txawv nyob rau sab saum toj ntawm lub rooj tsavxwm. Ntau qhov drilling, kuv paub

  • Kauj Ruam 2: Sim xaim ib lossis ob lub cim rau Raspberry Pi, xyuas seb lawv puas ua haujlwm. Koj xav txuas lawv mus rau MCP analog nyeem ntawv raws li tau piav qhia ua ntej hauv Kauj Ruam 2 (Cov duab qhia).
  • Kauj Ruam 3: Qhov no yuav yog qhov nyuaj thiab cuam tshuam rau lub paj hlwb, vim tias cov jumper lub taub hau tsis nyam heev hauv qhov chaw, koj yuav xav kaw lawv txhua tus rau hauv pawg thawj coj, ib tus zuj zus lossis ntau yam nyob rau ib zaug. Koj yuav tsum paub tseeb tias lawv nyob twj ywm ntawm lub chessboard, txwv tsis pub koj yuav tsis tuaj yeem nyeem cov ntsuas tau zoo

    TSWV YIM! Yog tias nws ua rau koj yooj yim dua, qee cov kua nplaum tuaj yeem pab ua kom lub ntsuas hluav taws xob ntau nyob hauv qhov chaw thaum kaw lawv, Kuv pom qhov no nyuaj

Kauj ruam 5: Software

Software
Software

Tom qab koj tau tsim kho vajtse uas koj tuaj yeem sim, cia peb sim sau qee qhov chaws rau nws! Yog tias koj xav tshuaj xyuas kuv tus lej, thov mus rau kuv tus github.

Back-endFirst peb yuav xav tau ob peb pob khoom los teeb tsa, kuv tau mus tom ntej thiab ua cov npe rau koj:

  • hwj

    Nov yog qhov koj tus nab npawb nab npawb nab npawb yuav ua haujlwm

  • Flask-socketIO

    Txhawm rau sib txuas lus ntawm pem hauv ntej-kawg thiab rov qab-kawg

  • xov

    Pab tau rau kev nyeem ntawv lub teeb pom kev zoo, ua haujlwm nrog cov lej

  • netifaces

    Txhawm rau luam koj tus kheej tus IP chaw nyob ntawm 7 ntu saib

  • Flask-CORS

    Hla hla keeb kwm kev rov thov dua tshiab, tso cai pob khoom sib koom ua ke sib txawv

Ntxiv rau qhov ntawd, kuv tau sau ob peb chav kawm thiab koj tau siv lawv dawb.

Pem hauv ntej-kawg

Lub vev xaib chaws tseem muaj nyob ntawm kuv nplooj ntawv github!

Rau pem hauv ntej-kawg Kuv yuav siv Chessboard.js. Qhov no ntxig rau ib qho yooj yim-rau-siv chessboard nrog cov khoom yooj yim-rau-txav!

Txhua yam ntawm lub rooj tsavxwm tuaj yeem tsim kho tau yog li muaj kev lom zem! Tom qab rub tawm qhov hloov tshiab kawg, koj yuav tsum rub cov ntaub ntawv mus rau hauv koj qhov project thiab txuas lawv mus rau nplooj ntawv uas koj xav qhia lub chessboard!

Tom qab ntawd, cia peb sim tsim lub rooj tsavxwm, tsis txhob nyuaj heev:

Ua ntej, hauv koj li html:

Qhov thib ob, hauv koj cov ntaub ntawv javascript:

board1 = ChessBoard ('board1', 'pib');

thiab muaj koj muaj nws, koj yuav tsum muaj peev xwm pom chessboard tam sim no! Xav tias dawb los kho lub rooj tsavxwm hauv CSS cov ntaub ntawv!

Tam sim no, peb xav pom qee qhov txav ntawm chessboard, tsis nyuaj heev. Tab sis peb yuav tsum tau kho nws kom cov lus txib txav mus tau xa rov qab. Kuv yuav tsis nkag mus ntau yam, tab sis peb xav ua qee yam zoo li no:

new_lijst = [Data.data [0], Data.data [1]; commando = new_lijst [0].concat ('-', new_lijst [1]); board1.move (commando);

Peb tau txais daim ntawv teev npe los ntawm peb qhov program-back-end programm, thiab muab lub cim rau nruab nrab ntawm ob txoj haujlwm, tom qab ntawd siv board.move hais kom ua qhov txav mus!

Qhov ntawd yog kuv piav qhia qhov peb xav tau ntawm chessboard.js plugin, taub hau rau kuv github txhawm rau saib tus lej koj tus kheej

Pom zoo: