Mundarija:
- Ta'minotlar
- 1 -qadam: Barcha komponentlarni lehimlash
- 2 -qadam: Hamma narsani joyiga joylashtiring
- 3 -qadam: dasturlash
- 4 -qadam: Xursand bo'ling !!
Video: Arduino yordamida DIY o'yin konsoli: 4 qadam
2024 Muallif: John Day | [email protected]. Oxirgi o'zgartirilgan: 2024-01-30 13:23
Ushbu qo'llanmada men sizga Arduino nano yordamida qanday qilib o'yin konsoli yasash mumkinligini ko'rsataman. Agar siz batafsil videoni ko'rishni xohlasangiz, youtube kanalimdan ko'ring
Ta'minotlar
Agar siz ushbu havolalardan sotib olsangiz, bu sizga ko'proq loyihalarni berishga yordam beradi
1) ARDUINO NANO2) OLED KO'RSATISH 3) TUGMA TUGMALARI 4) SIMLAR
1 -qadam: Barcha komponentlarni lehimlash
Shunday qilib, barcha komponentlarni olgandan so'ng, siz ushbu sxemada ko'rsatilganidek, barcha qismlarni lehimlashingiz kerak
2 -qadam: Hamma narsani joyiga joylashtiring
Lehimlashdan keyin hamma narsa shunday ko'rinishga ega bo'lishi uchun barcha komponentlarni shunday tartibga soling
3 -qadam: dasturlash
Shunday qilib, barcha amallarni to'g'ri bajarganingizdan so'ng, quyidagi kodni Arduino -ga yuklash vaqti keldi
#qo'shing
#include #include #include #include // #include #deleine OLED_RESET 4 Adafruit_SSD1306 displeyi (OLED_RESET); const int c = 261; const int d = 294; const int e = 329; const int f = 349; const int g = 391; const int gS = 415; const int a = 440; const int aS = 455; const int b = 466; const int cH = 523; const int cSH = 554; const int dH = 587; const int dSH = 622; const int eH = 659; const int fH = 698; const int fSH = 740; const int gH = 784; const int gSH = 830; const int aH = 880; const unsigned char PROGMEM dioda16 = {0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x3F, 0xF0, 0x3C, 0x00, 0x3C, 0x00, 0xFF, 0x00, 0x7F, 0xFF, 0x7F, 0xF, 0x1F, 0x1F, 0x00, 0x3C, 0x00, 0x1F, 0xF0, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00}; const unsigned char PROGMEM bo'ron = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00lik,, 0xFE, 0x00, 0x00, 0x00, 0x07, 0x80, 0x01, 0xE0, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x20, 0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00., 0x04, 0x00, 0x00, 0x20, 0x00, 0x00, 0x04, 0x00, 0x00, 0x20, 0x00, 0x00, 0x04, 0x00, 0x00, 0x60, 0x00, 0x00, 0x02, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x7F, 0xE0, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xD7, 0xFF, 0xFF, 0xE1, 0x00, 0x01, 0xBF, 0xBF, 0xBF, 0xFF, 0xBF, 0xF1, 0xCF, 0xFA, 0x80, 0x01, 0x3F, 0xC2, 0x37, 0xF7, 0x80, 0x01, 0xEF, 0x9C, 0x01, 0xE7, 0xC0, 0x01, 0xE0, 0x0, 0x70,, 0xC0, 0x03, 0x06, 0x80, 0x01, 0xFF, 0x80, 0x01, 0xFF, 0x80, 0x01, 0xF8, 0x00, 0x00, 0x1D, 0xC0, 0x03, 0x70, 0x00, 0x80, 0x0C, 0x60, 0x05, 0xB0, 0x07, 0xF0, 0x08, 0x90, 0x09, 0x10, 0x1F, 0xF8, 0x09, 0xD0, 0xD0, 0x01 0xF0, 0x0F, 0xC0, 0xFC, 0x0F, 0x07, 0x90, 0x0D, 0x43, 0xC0, 0x03, 0x07, 0x90, 0x05, 0x64, 0x00, 0x00, 0xCF, 0x10, 0x07, 0x07, 0xFC, 0x01, 0x80, 0x00, 0x00, 0x10, 0x20, 0x01, 0x00, 0x00, 0x00, 0x0E, 0x40, 0x01, 0x80, 0x07, 0xF0, 0x01, 0x80, 0x00, 0x80, 0x07, 0xC7, 0xC7 0x80, 0x0B, 0xE8, 0x00, 0x80, 0x00, 0x87, 0x97, 0xE9, 0xE0, 0x80, 0x00, 0x87, 0xDF, 0xEF, 0xA0, 0x80, 0x00, 0x4B, 0xFA, 0xFF, 0xFF, 0xF7 0xDF, 0xFB, 0xA3, 0x00, 0x00, 0x24, 0x97, 0xE8, 0x24, 0x00, 0x00, 0x1E, 0x1F, 0xC0, 0x2C, 0x00, 0x00, 0x07, 0xF8, 0x1F, 0x00, 0x00 0xF8, 0x00, 0x00}; void setup () {pinMode (3, INPUT_PULLUP); pinMod (12, INPUT_PULLUP); pinMod (11, INPUT_PULLUP); display.begin (SSD1306_SWITCHCAPVCC, 0x3C); display.display (); display.clearDisplay (); display.setTextSize (0); display.drawBitmap (6, 11, bo'ron, 48, 48, 1); display.setFont (& FreeSans9pt7b); display.setTextColor (oq); display.setCursor (65, 14); display.println ("xWing"); display.setFont (); display.setCursor (65, 17); display.setTextSize (0); display.println ("qarshi"); display.setCursor (0, 0); suzuvchi voltaza = readVcc ()/1000; displey.println (voltaza);; display.setFont (& FreeSans9pt7b); display.setCursor (65, 39); display.println ("O'lim"); display.setFont (); display.setCursor (65, 42); display.println ("yulduzcha"); display.setTextSize (0); display.setCursor (65, 55); display.println ("VRAJ tomonidan"); display.setCursor (65, 20); display.display (); display.setFont (); ovozli signal (a, 500); ovozli signal (a, 500); ovozli signal (a, 500); ovozli signal (f, 350); ovozli signal (cH, 150); ovozli signal (a, 500); ovozli signal (f, 350); ovozli signal (cH, 150); ovozli signal (a, 650); kechikish (500); kechikish (500); } int metx = 0; int mety = 0; int postoji = 0; int nep = 8; int smjer = 0; int go = 0; int rx = 95; int ry = 0; int rx2 = 95; int ry2 = 0; int rx3 = 95; int ry3 = 0; int bodovi = 0; int brzina = 3; // o'qning tezligi int bkugle = 1; int najmanja = 600; int najveca = 1200; int promjer = 10; int rx4 = 95; int ry4 = 0; int zivoti = 5; int poc = 0; int ispaljeno = 0; int nivo = 1; int sentar = 95; imzosiz uzun pocetno = 0; imzosiz uzun odabrano = 0; imzosiz uzun trenutno = 0; belgisiz uzun nivovrije = 0; int poz = 30; void loop () {if (go == 0) {display.clearDisplay (); display.drawPixel (50, 30, 1); display.drawPixel (30, 17, 1); display.drawPixel (60, 18, 1); display.drawPixel (55, 16, 1); display.drawPixel (25, 43, 1); display.drawPixel (100, 43, 1); display.drawPixel (117, 52, 1); display.drawPixel (14, 49, 1); display.drawPixel (24, 24, 1); display.drawPixel (78, 36, 1); display.drawPixel (80, 57, 1); display.drawPixel (107, 11, 1); display.drawPixel (150, 11, 1); display.drawPixel (5, 5, 1); display.drawPixel (8, 7, 1); display.drawPixel (70, 12, 1); display.drawPixel (10, 56, 1); display.drawPixel (70, 25, 1); agar (poc == 0) {pocetno = millis (); odabrano = tasodifiy (400, 1200); poc = 1; } trenutno = millis (); // nivoi if ((trenutno-nivovrije)> 50000) {nivovrije = trenutno; nivo = nivo+1; brzina = brzina+1; // brizna neprijateljevog metka if (nivo % 2 == 0) {bkugle = bkugle+1; promjer = promjer-1; } najmanja = najmanja-50; najveca = najveca-50; } if ((odabrano+pocetno) 0) {display.drawCircle (rx, ry, 2, 1); rx = rx-brzina;} if (ispaljeno> 1) {display.drawCircle (rx2, ry2, 1, 1); rx2 = rx2-brzina;} if (ispaljeno> 2) {display.drawCircle (rx3, ry3, 4, 1); rx3 = rx3-brzina;} if (ispaljeno> 3) {display.drawCircle (rx4, ry4, 2, 1); rx4 = rx4-brzina;} if (digitalRead (12) == 0 && poz> = 2) {poz = poz-2;} if (digitalRead (11) == 0 && poz128) postoji = 0; if (smjer == 0) {nep = nep+bkugle;} else {nep = nep-bkugle;} if (nep> = (64-promjer)) smjer = 1; if (nep = nep-promjer && mety (centar-promjer) && metx = pozicija-8 && ry <= pozicija+8) if (rx4) {rx = 95; ry = -50; ohang (9, 100, 100); zivoti = zivoti-1; } if (ry2> = pozicija-8 && ry2 <= pozicija+8) if (rx24) {rx2 = -50; ry2 = -50; ohang (9, 100, 100); zivoti = zivoti-1; } if (ry3> = pozicija-8 && ry3 <= pozicija+8) if (rx34) {rx3 = -50; ry3 = -50; ohang (9, 100, 100); zivoti = zivoti-1; } if (ry4> = pozicija-8 && ry4 <= pozicija+8) if (rx44) {rx4 = 200; ry4 = -50; ispaljeno = 0; ohang (9, 100, 100); zivoti = zivoti-1; } agar (rx4 <1) {ispaljeno = 0; rx4 = 200;} if (zivoti == 0) go = 1; } if (go == 1) {if (zivoti == 0) {ohang (9, 200, 300); kechikish (300); ohang (9, 250, 200); kechikish (200); ohang (9, 300, 300); kechikish (300); zivoti = 5; } display.clearDisplay (); display.setFont (); display.setTextSize (2); display.setTextColor (oq); display.setCursor (7, 10); display.println ("O'YIN TUTILDI!"); display.setTextSize (1); display.setCursor (7, 30); display.println ("ball:"); display.setCursor (44, 30); displey.println (bodovi); display.setCursor (7, 40); display.println ("daraja:"); display.setCursor (44, 40); display.println (nivo); display.setCursor (7, 50); display.println ("vaqt (lar):"); display.setCursor (60, 50); display.println (trenutno/1000); display.display (); if (digitalRead (3) == 0) {ohang (9, 280, 300); kechikish (300); ohang (9, 250, 200); kechikish (200); ohang (9, 370, 300); kechikish (300); ponovo (); }}} von ponovo () {metx = 0; met = 0; postoji = 0; nep = 8; smjer = 0; borish = 0; rx = 95; ry = 0; rx2 = 95; ry2 = 0; rx3 = 95; ry3 = 0; bodovi = 0; brzina = 3; // brizna neprijateljevog metka bkugle = 1; najmanja = 600; najveca = 1200; promijer = 12; rx4 = 95; ry4 = 0; zivoti = 5; poc = 0; ispaljeno = 0; nivo = 1; pocetno = 0; odabrano = 0; trenutno = 0; nivovrije = 0; } long readVcc () {// 1.1cc mos yozuvni AVccga qarshi o'qing // Vcc ga havolani va o'lchovni ichki 1.1V moslamasiga #if aniqlang (_ AVR_ATmega32U4_) || belgilangan (_ AVR_ATmega1280_) || belgilangan (_ AVR_ATmega2560_) ADMUX = _BV (REFS0) | _BV (MUX4) | _BV (MUX3) | _BV (MUX2) | _BV (MUX1); #elif belgilangan (_AVR_ATtiny24_) || belgilangan (_ AVR_ATtiny44_) || belgilangan (_ AVR_ATtiny84_) ADMUX = _BV (MUX5) | _BV (MUX0); #elif belgilangan (_AVR_ATtiny25_) || belgilangan (_ AVR_ATtiny45_) || belgilangan (_ AVR_ATtiny85_) ADMUX = _BV (MUX3) | _BV (MUX2); #boshqa ADMUX = _BV (REFS0) | _BV (MUX3) | _BV (MUX2) | _BV (MUX1); #endif kechikishi (2); // Vrefning ADCSRA ni hal qilishini kuting | = _BV (ADSC); // Konvertatsiya qilishni boshlash (bit_is_set (ADCSRA, ADSC)); // o'lchash uint8_t past = ADCL; // birinchi navbatda ADCL ni o'qishi kerak - keyin ADCH qulflanadi uint8_t high = ADCH; // ikkala uzoq natijani ham qulfdan chiqaradi = (yuqori << 8) | past; natija = 1125300L / natija; // Vccni hisoblash (mV da); 1125300 = 1.1*1023*1000 qaytarish natijasi; // Vcc millivoltsda} bo'sh signal (int note, int duration) {// BuzzerPin ohangida ijro etish ohangi (9, eslatma, davomiylik); kechikish (davomiyligi); noTone (9); kechikish (50); }
4 -qadam: Xursand bo'ling !!
Tabriklaymizmi? Siz nihoyat shunday qildingiz, agar sizga yoqqan bo'lsa, youtube kanalimga obuna bo'ling
Tavsiya:
DIY Raspberry Pi Zero portativ o'yin konsoli: 6 qadam (rasmlar bilan)
DIY Raspberry Pi Zero qo'lda ishlaydigan o'yin konsoli: Ushbu loyihada men sizga Raspberry Pi Zero, NiMH batareyalari, uydan ortiqcha zaryadsizlanishdan himoya qilish sxemasi, orqa ko'zoynak va audio kuchaytirgichni qanday ishlatilishini ko'rsataman. retro o'yinlar. Qani boshladik
Raspberry Pi yordamida o'yin konsoli yarating!: 6 qadam
Raspberry Pi -dan foydalanib o'yin konsoli yarating!: Siz qimmatbaho eski pristavkalarni to'lamasdan retro o'yinlar o'ynashni xohlaysizmi? Siz buni Raspberry Pi yordamida qilishingiz mumkin. Raspberry Pi-bu " kredit karta o'lchamidagi kompyuter " Bu juda ko'p ajoyib narsalarga qodir. Turli xil turlari bor
Arduino asosidagi DIY o'yin boshqaruvchisi - Arduino PS2 o'yin boshqaruvchisi - DIY Arduino Gamepad bilan Tekken o'ynash: 7 qadam
Arduino asosidagi DIY o'yin boshqaruvchisi | Arduino PS2 o'yin boshqaruvchisi | DIY Arduino Gamepad bilan Tekken o'ynash: Salom bolalar, o'yin o'ynash har doim qiziqarli, lekin o'zingizning shaxsiy o'yiningiz bilan o'ynash yanada qiziqarli, shuning uchun biz ushbu qo'llanmada arduino pro micro yordamida o'yin boshqaruvchisi qilamiz
2.2 TFT yordamida qo'lda qayta quti o'yin konsoli: 6 qadam
2.2 TFT yordamida qo'lda qayta qutiga solingan o'yin konsoli: 2.2 "TFT LCD va Raspberry Pi 0 W va GPIO tugmachalari yordamida qo'lda qayta qutiga o'rnatilgan o'yin konsoli uchun ko'rsatmalar. Siz bu youtube videosini ko'rishingiz mumkin. Barcha qismlarni oling B. Qismlarni bir -biriga lehimlang
Arduino cho'ntak o'yin konsoli + A -labirint - labirint o'yini: 6 qadam (rasmlar bilan)
Arduino cho'ntak o'yini konsoli + A -labirint - Maze o'yini: Mening birinchi ko'rsatmaga xush kelibsiz! Men bugun siz bilan baham ko'rmoqchi bo'lgan loyiham Arduino labirint o'yini bo'lib, u Arduboy va shunga o'xshash Arduino konsollari kabi cho'ntak konsoliga aylandi. Buni Expo tufayli mening (yoki sizning) bo'lajak o'yinlarim bilan ko'rsatish mumkin