Cov txheej txheem:
- Kauj ruam 1: YUAV TSUM
- Kauj ruam 2: SCHEMA
- Kauj ruam 3: CODE
- Kauj ruam 4: CODE BITMAP
- Kauj Ruam 5: Ua Tsaug rau Kev Pom
Video: Arduino Space Race Game Version _1: 5 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Nyob zoo phooj ywg. Hnub no kuv xav qhia koj yuav ua li cas koj tuaj yeem ua Space Space Game Game los ntawm LCD5110 npo thiab zoo siab.
Kauj ruam 1: YUAV TSUM
Nov yog cov npe ntawm ntu uas kuv tau siv los ua txoj haujlwm no:
- Arduino UAS
- Joystick Module
- Jumper Wires (txiv neej rau txiv neej thiab txiv neej rau poj niam)
- Cov qhob cij
Kauj ruam 2: SCHEMA
VCC -> Arduino 5V
BL -> Arduino tus pin 3
GND -> Arduino GND
CLK (SCLK) -> Arduino tus pin 8
DIN (MOSI) -> Arduino tus pin 9
DC -> Arduino tus pin 10
CE lossis CS -> Arduino tus pin 12
RST (RESET) -> Arduino tus pin 11
Kauj ruam 3: CODE
Txoj cai tau piav qhia txog kev ua haujlwm. Koj yuav nkag siab nws yooj yim. Yog tias koj muaj teeb meem, koj tuaj yeem tiv tauj kuv.
#suav nrog
LCD5110 lcd (8, 9, 10, 11, 12); // (clk, din, dc, rst, ce)
int BL = 3;
sab nrauv uint8_t SmallFont ; // piav qhia cov fonts sab nrauv uint8_t MediumNumbers ; sab nrauv uint8_t arac ; // piav qhia peb cov duab sab nrauv uint8_t dusman_araci ; // desribe yeeb ncuab zoo const int xpin = A0; // joystick x pin char pozisyon = 2; // piav qhia qhov chaw nyob, peb cov duab pib qhov chaw 2 boolean kontrol = tseeb; boolean dusmanOldu = muaj tseeb; int skor = 0; int hais = 0; koj dusmanKonumu1; // piav qhia tus yeeb ncuab1 x qhov chaw int dusmanKonumu2; // piav qhia tus yeeb ncuab2 x qhov chaw int dusmaninYdeKonumu; // piav qhia cov yeeb ncuab y qhov chaw nyob
void dusmanAraci (int yer, int asama) {// teeb tsa qhov chaw rau cov yeeb ncuab duab
yog (yer == 1) {// yog qhov chaw = 1; lcd.drawBitmap (2, asama, dusman_araci, 12, 8); // kos tus yeeb ncuab lub cev} yog (yer == 2) {lcd.drawBitmap (18, asama, dusman_araci, 12, 8); } yog (yer == 3) {lcd.drawBitmap (34, asama, dusman_araci, 12, 8); }}
tsis muaj dab tsi oyunBitti () {// yog tias peb ua tsis tiav, qhov kev ua si dhau
thaum (1) {ncua (100); // tos 1 lub hlis lcd.clrScr (); // tshem qhov screen lcd.setFont (SmallFont); // teeb tsa lcd.print ("GAME OVER", CENTER, 20); // luam tawm lcd.update (); // hloov kho qhov screen}}
teeb tsa tsis muaj dab tsi () {pinMode (BL, OUTPUT); // teeb rov qab teeb tso zis lcdInitLCD (); // pib lub lcd screen lcd.setContrast (55); // teeb qhov sib txawv (amound 0 txog 127) Serial.begin (9600); // pib serial comunation}
void voj () {
analogWrite (BL, 200);
// teeb tsa game lcd.drawRect (0, 0, 47, 47); // peb kos duab plaub lcd.setFont (SmallFont); // teeb tsa lcd.print ("skor", 53, 0); // printf qhab nia lcd.setFont (MediumNumbers); // teeb tsa lcd.printNumI (skor, 59, 7); // tau qhab nia lcd.setFont (SmallFont); lcd.print ("hiz", 56, 25); // luam ceev lcd.setFont (MediumNumbers); lcd.printNumI (hiz, 59, 32); // tau ceev lcd.update (); // hloov tshiab
// teeb tsa qhov chaw joyistick int x = analogRead (xpin); if (x <300 && pozisyon! = 1 && kontrol == true) {// yog qhov chaw! = 1, x state600 && pozisyon! = 3 && kontrol == true) {// yog qhov chaw! = 3, x xeev> 600 thiab tswj yog qhov tseeb pozisyon ++; // nce qhov chaw nws txhais tau tias txav cov duab mus rau txoj cai kontrol = cuav; } lwm yog (x> 300 && x <600) {kontrol = tseeb; } Serial.println (x); // rau kev kawm x lub xeev // teeb tsa peb qhov chaw zoo lcd.clrScr (); // tshem qhov screen yog (pozisyon == 1) {// yog qhov chaw = 1; lcd.drawBitmap (2, 37, arac, 12, 8);} // kos peb lub nkoj yog (pozisyon == 2) {lcd.drawBitmap (18, 37, arac, 12, 8);}
yog (pozisyon == 3) {
lcd.drawBitmap (34, 37, arac, 12, 8);}
yog (dusmanOldu) {// yog tias cov yeeb ncuab zoo li tuag lawm, xyuas seb lawv puas tuag
dusmanKonumu1 = pozisyon; // kos thawj tus yeeb ncuab zoo dusmanKonumu2 = random (0, 4); // kos lwm tus yeeb ncuab zoo ib yam dusmaninYdeKonumu = 0; // coj tus yeeb ncuab los saum dusmanOldu = cuav;} // yeeb ncuab rov tsim dua kom lawv tsis tuag dusmanAraci (dusmanKonumu1, dusmaninYdeKonumu); dusmaninYdeKonumu ++; // kos thawj tus yeeb ncuab zoo thiab tau txais nws los ntawm sab saum toj mus rau hauv qab dusmanAraci (dusmanKonumu2, dusmaninYdeKonumu); dusmaninYdeKonumu ++; // kos tus yeeb ncuab thib ob zoo thiab tau txais nws los ntawm sab saum toj mus rau hauv qab yog (dusmaninYdeKonumu> 22 && ((dusmanKonumu1 == pozisyon) || (dusmanKonumu2 == pozisyon)))) {// yog tias peb lub cev kov cov yeeb ncuab lub cev oyunBitti ();} // qhov kev ua si dhau yog (dusmaninYdeKonumu> 40) {// yog tias peb lub cev khiav tawm ntawm cov yeeb ncuab dusmanOldu = muaj tseeb; // tua cov yeeb ncuab lub cev skor ++;} // nce ib los ntawm ib tus qhab nia // nce nrawm raws li tus qhab nia yog (skor> = 0 && skor10 && skor20 && skor30 && skor <= 40) {hiz = 3; ncua (40); }}
Kauj ruam 4: CODE BITMAP
Ib qho ntxiv, koj yuav tsum suav nrog cov duab bitmap rau cov duab.
// ----------------------------------------------------------------------- ------------------------------ // Cov ntaub ntawv tsim los ntawm LCD Assistant // https://en.radzio.dxp.pl /bitmap_converter/// ------------------------------------------------------- --------------------------------- #suav nrog // suav nrog rau txoj haujlwm ua haujlwm
const unsigned char arac PROGMEM = {// peb cov duab bitmap
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
const unsigned char dusman_araci PROGMEM = {// yeeb ncuab nkoj bitmap
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
Kauj Ruam 5: Ua Tsaug rau Kev Pom
Ua ntej ı pib qhia kuv cov haujlwm, ı coded ua lus Turkish yog li kuv tsis tuaj yeem muaj txhua lo lus rau lus Askiv. Ntawm no cov lus txhais lus uas siv qhov haujlwm no, Yog = Game
Arac = Cov duab
Dusman = Yeeb ncuab
kontrol = tswj
Konum, Yer = Qhov chaw
Oyun Bitti = Game Over
Skor = Cov qhab nia
Hiz = Ceev
Pom zoo:
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
Cov Ntawv Cim Hluav Taws Xob LED Taws Teeb Cov Neeg Hlau Cov Ntawv Cim - Cov Khoom Siv Soldering: 11 Kauj Ruam
Cov Khoom Siv Hluav Taws Xob LED Taws Teeb Cov Neeg Hlau Daim Npav - Cov Khoom Siv Soldering: 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. Robadge#1 uas kuv tau tsim rau
Olympus Evolt E510 Cov Hluav Taws Xob Hluav Taws Xob Tshaj Tawm (Version 2 Nrog Pib Ua Haujlwm ntawm Chaw Taws Teeb): 6 Cov Kauj Ruam (nrog Duab)
Olympus Evolt E510 Cov Hluav Taws Xob Hluav Taws Xob Tso Tawm (Version 2 Nrog Pib Ua Haujlwm ntawm Cov Chaw Taws Teeb): Nag hmo Kuv tau tsim lub khawm yooj yim ib qho chaw taws teeb rau kuv Olympus E510. Cov koob yees duab feem ntau muaj lub khawm kaw (qhov uas koj thawb kom thaij duab) uas muaj ob hom. Yog tias khawm maj mam nyuaj siab, lub koob yees duab yuav pib tsom thiab ntsuas lub teeb