Cov txheej txheem:
- Kauj Ruam 1: Daim Ntawv Teev Npe:
- Kauj Ruam 2: Kev Kho Vajtse Txuas
- Kauj ruam 3: Programming
- Kauj Ruam 4: Kev sim ua tiav
Video: NeoPixels Matrix Game Snake Game: 4 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:25
Koj puas tseem nco tau game nab nab ua si ntawm peb lub npov game lossis mobile thaum peb tseem yau? Hnub no peb yuav kawm paub yuav ua li cas ua si nab nrog 8*8 NeoPixels Matrix. Peb xaiv Arduino uno ua lub chaw tswj hwm thiab Joystick breakout module los tswj tus nab.
Kauj Ruam 1: Daim Ntawv Teev Npe:
Kho vajtse:
1 X Freaduino UNO Rev2.2 MB_EFUNO
1 X Saj Zawg Zog 64 RGB LED 8*8 NeoPixels Matrix
1 X Joystick breakout module BKOUT_MD01
3 X Qhia Kab
Software:
Arduino IDE Cov
Kauj Ruam 2: Kev Kho Vajtse Txuas
Txuas NeoPixels rau tus pin D2.
"X" ntawm Joystick breakout module txuas tus pin A0 ntawm Arduino UNO board, "Y" txuas tus pin A1, "K" txuas tus pin A2.
Kauj ruam 3: Programming
P#suav nrog
#define PIN 2 // Pin Pin #define MAX_LED 64 // Quantity ntawm cov hlaws uint32_t c; int ib = 0, tus lej; unsigned char huan = 0, ci = 0; unsigned char u = 40; // Cov ntawv loj ntawm pawg lus tsis kos npe x = 0; unsigned char Xim [3]; unsigned char go = {2, 3, 4, 5, 9, 14, 17, 20, 22, 26, 27, 29, 34, 35, 36, 37, 41, 46, 49, 54, 58, 59 60, 61; ib. // 24 unsigned char light [8] [8] = {{0, 1, 2, 3, 4, 5, 6, 7}, {15, 14, 13, 12, 11, 10, 9, 8}, {16, 17, 18, 19, 20, 21, 22, 23}, {31, 30, 29, 28, 27, 26, 25, 24}, {32, 33, 34, 35, 36, 37, 38, 39}, {47, 46, 45, 44, 43, 42, 41, 40}, {48, 49, 50, 51, 52, 53, 54, 55}, {63, 62, 61, 60, 59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0, 0}, {0, 1, 0, 1, 0, 1, 0, 0}, // 9 {0, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0 },}; Ib unsigned char displayscore [8] [8]; int speedS = 400; // Thawj qhov nrawm ntawm nab tus qhab nia; // Game score int xValue; // JoyStick-X int yValue; // JoyStick-Y int zValue; // JoyStick-Z int FX, FY; // Sib koom zaub mov int SX, SY; // Kev sib koom tes ntawm nab taub hau KEY, K; int Qhib; // Pab kom rov pib game char sx [64]; // Sib koom ntawm nab lub cev char sy [64]; Adafruit_NeoPixel strip = Adafruit_NeoPixel (MAX_LED, PIN, NEO_RGB + NEO_KHZ800); tsis muaj dab tsi RANDOM () {A: FX = random (0, 7); FY = random (0, 7); rau (int i = 0; i <3+qhab nia; i ++) // Tiv thaiv zaub mov zaub ntawm nab lub cev {yog (FX == sx && FY == sy ) goto A; }} void myDelay (unsigned int Time) {// Lub sijhawm ncua ntawm kev txav ntawm nab, peb yuav tsum ua qee yam xws li zaub mov ci thiab nyeem cov lus qhia ntawm Joystick rau (int t = 1; t 950 && KEY! = 5) { K = 8; } lwm yog (yValue <50 && KEY! = 8) {K = 5; } lwm yog (xValue 950 && KEY! = 4) {K = 6; }} // Ntawm no koj tuaj yeem sib piv seb qhov kev taw qhia ntawm cov keyboard yog rov qab rau tus nab txav mus. Yog hais tias nws yog rov qab, ces muab cov keyboard. /********************************************************** ********************************************************** ****** ********************************************************** ****** ********************************************************** ****** ********/ void gameover () {// Thaum Gameover program nres, nias lub hauv paus khawm kom rov pib ua si. tsis kos npe tus nqi, y; Xim [0] = random (3, 18); // Teeb xim. Parameter yog R G B, thaj tsam 0-255. Xim [1] = random (3, 18); Xim [2] = random (3, 18); c = strip. Color (Xim [1], Xim [0], Xim [2]); tus nqi = qhab nia / 10; tus nqi = tus nqi * 4; y = 0; rau (tus lej = tus nqi; tus lej <tus nqi+4; tus lej ++) {rau (tsis tau kos npe kab ntsug = 0; ntsug <8; ntsug ++) {displaycore [y] [ntsug] = cim [tus lej] [ntsug]; } y ++; } tus nqi = qhab nia % 10; tus nqi = tus nqi * 4; rau (tus lej = tus nqi; tus lej <tus nqi+4; tus lej ++) {rau (tsis tau kos npe kab ntsug = 0; ntsug <8; ntsug ++) {displaycore [y] [ntsug] = cim [tus lej] [ntsug]; } y ++; } rau (unsigned char horizontal = 0; horizontal <8; horizontal ++) {for (unsigned char vertical = 0; vertical <8; vertical ++) {if (displayscore [horizontal] [vertical] == 1) // Txiav txim seb lub teeb yog nyob rau {strip.setPixelColor (lub teeb [kab rov tav] [ntsug], c); } lwm tus strip.setPixelColor (lub teeb [kab rov tav] [ntsug], 0); }} strip.show (); // Xa cov ntaub ntawv ncua (5000); K = 0; // Pib dua Joystick kev taw qhia sx [0] = 2; sx [1] = 1; tx [2] = 0; sy [0] = 1; sy [1] = 1; sy [2] = 1; // Pib dua tus nab sib tw qhab nia = 0; // Pib dua cov qhab nia game speedS = 400; // Thawj qhov ceev ntawm nab} void teeb () {Serial.begin (9600); // Pib lub tsev qiv ntawv strip.begin (); // Xa cov ntaub ntawv. Default xim ntawm txhua lub ntsiab lus raws li 0. Yog li txhua lub ntsiab lus tsis pom kev thaum pib. strip.show (); K = 0; // Pib dua qhov kev taw qhia ntawm Joystick sx [0] = 2; sx [1] = 1; tx [2] = 0; sy [0] = 1; sy [1] = 1; sy [2] = 1; // Pib dua tus nab sib tw qhab nia = 0; // Rov ua dua cov qhab nias game Xim [0] = random (3, 18); // Teeb xim. Parameter yog R G B, thaj tsam 0-255. Xim [1] = random (3, 18); Xim [2] = random (3, 18); c = strip. Color (Xim [1], Xim [0], Xim [2]); // Ntsuab Liab Xiav // Teeb xim rau (tus lej = 0; tus lej <24; tus lej ++) {strip.setPixelColor (mus [tus lej], c); } strip.show (); // Xa cov ntaub ntawv ncua (2000); RANDOM (); // Ua zaub mov} tsis muaj dabtsis mobile () {KEY = K; // Txhua qhov kev txav ntawm nab ua rau kev hloov pauv ib zaug. if (KEY == 8) // Snake upward movement {for (int i = 2 + score; i> 0; i--) {sx = sx [i-1]; sy = sib [i - 1]; } sy [0] = sy [0] - 1; yog (sy [0] <0) // Mus dhau ciam teb thiab txuas ntxiv mus rau lwm sab sy [0] = 7; } lwm tus yog (KEY == 5) // Snake downward txav {rau (int i = 2 + qhab nia; i> 0; i--) {sx = sx [i-1]; sy = sib [i - 1]; } sy [0] = sy [0] + 1; yog (sy [0]> 7) // Mus dhau ntawm ciam teb thiab txuas ntxiv mus rau lwm sab sy [0] = 0; } lwm yog (KEY == 4) // Nab laug txav mus {rau (int i = 2 + qhab nia; i> 0; i--) {sx = sx [i-1]; sy = sib [i - 1]; } sx [0] = sx [0] - 1; yog (sx [0] <0) // Mus hla ciam teb thiab txuas ntxiv mus rau lwm sab sx [0] = 7; } lwm yog (KEY == 6) // Nab txoj cai txav {rau (int i = 2 + qhab nia; i> 0; i--) {sx = sx [i-1]; sy = sib [i - 1]; } sx [0] = sx [0] + 1; yog (sx [0]> 7) // Mus dhau ciam teb thiab txuas ntxiv mus rau lwm sab sx [0] = 0; } // Tsiv lub cev nab nrog khawm} void qhia () {rau (tus lej = 0; tus lej <64; tus lej ++) // Tshem qhov screen {strip.setPixelColor (tus lej, 0); } strip.show (); Xim [0] = 40; // Teeb xim. Parameter yog R G B, thaj tsam 0-255. Xim [1] = 0; Xim [2] = 0; c = strip. Color (Xim [1], Xim [0], Xim [2]); // Ntsuab Liab Xiav // Teeb xim x = teeb [FX] [FY]; // Zaub zaub strip.setPixelColor (x, c); Xim [0] = random (3, 18); // Teeb xim. Parameter yog R G B, thaj tsam 0-255. Xim [1] = random (3, 18); Xim [2] = random (3, 18); c = strip. Color (Xim [1], Xim [0], Xim [2]); // Ntsuab Liab Xiav // Teeb xim rau (int i = 2 + qhab nia; i> 0; i--) // Zaub cev cev {x = lub teeb [sx [sy ; strip.setPixelColor (x, c); } Xim [0] = 0; // Teeb xim. Parameter yog R G B, thaj tsam 0-255. Xim [1] = 40; Xim [2] = 0; c = strip. Color (Xim [1], Xim [0], Xim [2]); // Ntsuab Liab Xiav // Teeb xim x = lub teeb [sx [0] [sy [0]; // Zaub nab taub hau strip.setPixelColor (x, c); strip.show (); // Xa cov ntaub ntawv} void loop () {mobile (); myDelay (speedS); // Tsis pub dhau () yog ncua sijhawm. qhia (); SX = tx [0]; SY = sib [0]; // Tau txais kev koom tes ntawm tus nab lub taub hau rau (int i = 1; i <= 2+qhab nia; i ++) {yog (SX == sx && SY == sy ) gameover (); } // Txiav txim seb nab lub taub hau kov nws lub cev. Yog tias kov, tom qab ntawd xa mus rau GameOver. yog (SY == FY && SX == FX) {RANDOM (); qhab nia ++; Xim [0] = 40; // Teeb xim. Parameter yog R G B, thaj tsam 0-255. Xim [1] = 0; Xim [2] = 0; c = strip. Color (Xim [1], Xim [0], Xim [2]); // Ntsuab Liab Xiav // Teeb xim x = teeb [FX] [FY]; // Zaub zaub strip.setPixelColor (x, c); strip.show (); // Xa cov ntaub ntawv yog (! (qhab nia % 5)) {// Ua kom nrawm nab raws li tus qhab nia. Txhua 5 zaub mov noj, ua kom nrawm dua 100ms. speedS = speedS - 50; yog (speedS <150) // Qhov txwv qis tshaj yog 200ms. Yog tias nrawm dua 200ms, qhov nrawm nyob 200ms. speedS = 150; }} // Txiav txim seb zaub mov puas noj. Yog tias nab tau noj zaub mov, tom qab ntawd ntxiv cov qhab nia thiab rov tsim cov zaub mov tsis raug. }
Kev sim ua tiav
Kauj Ruam 4: Kev sim ua tiav
Nyeem txheeb ze:
FreaksBot Bluetooth Tsheb
Teeb thawj Bead ntawm 8*8 NeoPixels Matrix nrog Arduino
Micro: kev sim me me 05: RGB LED - Elecfreaks Mirco: ntsis Cov Khoom Pib Pib
Hnub Friday Khoom Tshaj Tawm: LED Music Zaus Spectrum Zaub Soldering Khoom
Siv ElecFreaks Micro: ntsis Tinker Kit los Ua Lub Teeb Ntse
Pom zoo:
Cov Sijhawm Digital LED Dot Matrix - ESP Matrix Android App: 14 Cov Kauj Ruam
Digital Clock LED Dot Matrix - ESP Matrix Android App: Kab lus no tau txaus siab txhawb nqa los ntawm PCBWAY.PCBWAY ua cov qauv zoo PCBs rau tib neeg thoob plaws ntiaj teb. Sim nws rau koj tus kheej thiab tau txais 10 PCBs rau tsuas yog $ 5 ntawm PCBWAY nrog qhov ua tau zoo heev, Ua tsaug PCBWAY. ESP Matrix Board uas kuv deve
Hloov-Hloov Cov Khoom Ua Si: Cov Khoom Ua Si Cov Khoom Ua Si Ua Tau Zoo!: 7 Cov Kauj Ruam (nrog Duab)
Hloov-Hloov Cov Khoom Ua Si: Cov Khoom Siv Hluav Taws Xob Ua Tau Zoo!: Qho khoom ua si hloov pauv qhib txoj hauv kev tshiab thiab kev daws teeb meem kom tso cai rau menyuam yaus uas muaj lub cev muaj peev xwm txwv lossis kev xiam oos qhab kev loj hlob los cuam tshuam nrog cov khoom ua si ntawm nws tus kheej. Hauv ntau qhov xwm txheej, cov menyuam yaus uas xav tau cov khoom ua si hloov pauv tsis tuaj yeem nkag mus
Cov av noo noo Cov Lus Qhia Tswj Xyuas Internet Txuas Cov Dej Dej (ESP32 thiab Blynk): 5 Cov Kauj Ruam
Cov av noo noo Cov lus pom zoo Tswj Xyuas Internet Txuas Cov Dej Dej (ESP32 thiab Blynk): Tsis txhawj xeeb txog koj lub vaj lossis nroj tsuag thaum koj mus rau hnub so ntev, lossis tsis nco qab ywg dej koj cov nroj tsuag txhua hnub. Zoo ntawm no yog kev daws teeb meem Nws cov av ya raws tswj hwm thiab thoob ntiaj teb txuas nrog cov dej txau dej tswj los ntawm ESP32 ntawm software pem hauv ntej kuv
Ua Cov Phiaj Xwm Zoo Los Ntawm Cov Ntaub Ntawv Nyob Arduino (thiab Txuag Cov Ntaub Ntawv rau Excel): 3 Cov Kauj Ruam
Ua Cov Phiaj Xwm Zoo Los Ntawm Cov Ntaub Ntawv Nyob Arduino (thiab Txuag Cov Ntaub Ntawv rau Excel): Peb txhua tus nyiam ua si nrog peb tus lej L … cov ntsiab lus tau ntxiv thiab nws tsis tshwj xeeb rau lub qhov muag. Arduino IDE cov phiaj xwm tsis
Kev teeb tsa Matrix LED hauv Cov Khoom Siv Hluav Taws Xob qub - Yuav Tsum Tau Cov Khoom Siv: 3 Cov Kauj Ruam (nrog Duab)
Kev teeb tsa Matrix LED hauv Cov Khoom Siv Hluav Taws Xob qub - Yuav Tsum Tau Siv Cov Khoom Siv: Lub teeb pom kev zoo los ntawm lub Windows PC dhau Bluetooth thiab LED cov txheej txheem nthuav tawm Ib co piv txwv ntawm pixel kos duab thiab cov duab ua haujlwm khiav ntawm LED Cov Ntsiab Lus ntawm PIXEL Guts Kit Hauv Cov Lus Qhia no, peb ' yuav