Cov txheej txheem:
- Kauj ruam 1: PARTS
- Kauj ruam 2: SCHEMA
- Kauj ruam 3: CODE
- Kauj ruam 4: CODE BITMAP
- Kauj Ruam 5: Ua Tsaug Rau Saib
Video: Chaw Sib Tw Ua Si Version 2: 5 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:27
Hav sawv daws. Ua ntej qhov game game version, ı luam tawm thawj version ntawm game. Hnub no, ı yuav qhia koj qhov Chaw Sib Tw Sib Tw version 2. Cia saib cov kauj ruam…
Kauj ruam 1: PARTS
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, cin, dc,, rst, ce)
boolean kontrol = tseeb;
boolean dusmanoldu = tseeb;
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 dusmanAraci ; // desribe yeeb ncuab zoo const int xpin = A0; // joystick x pin char pozisyon = 3; // piav qhia qhov chaw nyob, peb cov duab pib qhov chaw 3 int BL = 3; int skor = 0; int hais = 0; koj dusmankonum1; // piav qhia tus yeeb ncuab1 x qhov chaw int dusmankonum2; // piav qhia tus yeeb ncuab2 x qhov chaw int dusmankonum3; // piav qhia tus yeeb ncuab3 x qhov chaw int dusmankonum4; // piav qhia tus yeeb ncuab4 x qhov chaw int dusmankonum5; // piav qhia tus yeeb ncuab5 x qhov chaw int dusmaninYdekonumu;
void oyunEkrani () {// teeb tsa game screen
lcd.clrScr (); lcd.drawRect (0, 0, 47, 47); // peb kos duab plaub lcd.setFont (SmallFont); // teeb tsa lcd.print ("skor", 57, 1); // luam tau qhab nia lcd.print ("hiz", 60, 24); // luam ceev lcd.setFont (MediumNumbers); // teeb tsa lcd.printNumI (sau, 55, 8); // tau qhab nia lcd.printNumI (hiz, 63, 32); // tau ceev lcd.update (); }
void dusmanAracidurum (int yer, int asama) {// teeb tsa qhov chaw rau cov yeeb ncuab duab
yog (yer == 1) {lcd.drawBitmap (2, asama, dusmanAraci, 7, 7); lcd.update ();} // yog qhov chaw = 1 kos tus yeeb ncuab lub chaw no yog (yer == 2) {lcd.drawBitmap (10, asama, dusmanAraci, 7, 7); lcd.update ();} yog (yer == 3) {lcd.drawBitmap (18, asama, dusmanAraci, 7, 7); lcd.update (); } yog (yer == 4) {lcd.drawBitmap (26, asama, dusmanAraci, 7, 7); lcd.update ();} yog (yer == 5) {lcd.drawBitmap (34, asama, dusmanAraci, 7, 7); lcd.update ();} yog (yer == 6) {lcd.drawBitmap (42, asama, dusmanAraci, 7, 7); lcd.update ();}}
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 (); lcd.setFont (SmallFont); lcd.print ("OYUN BITTI", CENTER, 8); // luam game hla lcd.print ("skorunuz =", 3, 30); // luam koj cov qhab nia lcd.setFont (MediumNumbers); lcd.printNumI (skor, 60, 25); // tau qhab nia kawg lcd.update (); }}
void teeb tsa () {
pinMode (BL, NTAWV); // teeb tsa rov qab teeb Cov zis pinMode (xpin, INPUT); // teeb x tus pin raws li kev nkag 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, 350); oyunEkrani ();
// joyistic durumu … // teeb tsa qhov chaw joyistick …
int durumx = analogRead (xpin); if (durumx <300 && pozisyon! = 1 && kontrol == true) {// yog qhov chaw! = 1, x state600 && pozisyon! = 6 && 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 tus yog (durumx> 300 && durumx <600) {kontrol = tseeb; } // pozisyon durumu… // txoj haujlwm lub xeev… yog (pozisyon == 1) {// yog qhov chaw = 1; lcd.drawBitmap (2, 41, arac, 7, 7); lcd.update ();} // kos peb lub nkoj yog tias (pozisyon == 2) {lcd.drawBitmap (10, 41, arac, 7, 7); lcd.update ();} yog (pozisyon == 3) {lcd.drawBitmap (18, 41, arac, 7, 7); lcd.update ();} yog (pozisyon == 4) {lcd.drawBitmap (26, 41, arac, 7, 7); lcd.update ();} yog (pozisyon == 5) {lcd.drawBitmap (34, 41, arac, 7, 7); lcd.update ();} yog (pozisyon == 6) {lcd.drawBitmap (42, 41, arac, 7, 7); lcd.update ();}
yog (dusmanoldu) {// yog tias cov yeeb ncuab zoo li tuag lawm, xyuas seb lawv puas tuag
dusmankonum1 = pozisyon; // kos thawj tus yeeb ncuab zoo dusmankonum2 = random (0, 6); // kos lwm tus yeeb ncuab zoo ib yam dusmankonum3 = random (0, 6); dusmankonum4 = random (0, 6); dusmankonum5 = random (0, 6); dusmaninYdekonumu = 0; // coj yeeb ncuab los saum dusmanoldu = cuav;} // yeeb ncuab rov tsim dua kom lawv tsis tuag
dusmanAracidurum (dusmankonum1, dusmaninYdekonumu); dusmaninYdekonumu ++; // kos thawj tus yeeb ncuab zoo thiab tau txais nws los ntawm sab saum toj mus rau hauv qab
dusmanAracidurum (dusmankonum2, dusmaninYdekonumu); dusmaninYdekonumu ++; // kos tus yeeb ncuab thib ob zoo thiab tau txais nws los ntawm sab saum toj mus rau hauv qab dusmanAracidurum (dusmankonum3, dusmaninYdekonumu); dusmaninYdekonumu ++; dusmanAracidurum (dusmankonum4, dusmaninYdekonumu); dusmaninYdekonumu ++; yog (dusmaninYdekonumu> 35 && ((dusmankonum1 == pozisyon) || (dusmankonum2 == pozisyon) || (dusmankonum3 == pozisyon) || (dusmankonum4 == pozisyon))))); // qhov kev ua si dhau lawm}
yog (dusmaninYdekonumu> 42) {// yog tias peb lub cev khiav tawm ntawm cov yeeb ncuab
dusmanoldu = tseeb; // tua yeeb ncuab duab skor ++; // nce ib los ntawm ib tus qhab nia}
// skora gore hizi artiriyoruz // nce nrawm raws li tus qhab nia
yog (skor> = 0 && skor = 10 && skor = 20 && skor = 30 && skor = 40 && skor = 50) {hiz = 6; ncua (5); }
}
Kauj ruam 4: CODE BITMAP
Ntxiv mus, koj yuav tsum suav nrog cov duab bitmap rau cov duab nws yuav tsum yog.c cov ntaub ntawv.
#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,};
const unsigned char dusmanAraci PROGMEM = {// yeeb ncuab nkoj bitmap
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
Kauj Ruam 5: Ua Tsaug Rau Saib
Lub ntsiab lus ntawm qee cov lus:
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:
THIAB LUB NEEJ !! (Sib tham sib tham rooj sib tham): 4 Kauj Ruam
THIAB LUB NEEJ !! (sib tham sib tham txog Thruth Table): Nyob zoo cov phooj ywg, Kuv vam tias koj txhua tus nyob hauv koj lub tsev zoo thiab xav tsis thoob dab tsi ntawm cov ntaub ntawv uas muaj ?? Nkag siab cov rooj vag logic yog qhov tseem ceeb heev rau ob leeg
Yooj Yim Cov Chaw Siv Cov Ntaub Ntawv Hauv Chaw Siv Hauv / Arduino / PfodApp: 6 Cov Kauj Ruam
Yooj Yim Cov Ntaub Ntawv Tseem Ceeb Siv Hauv Hauv/Arduino/PfodApp: Rau Plotting Cov Ntaub Ntawv tawm tsam Hnub/Sijhawm siv tsuas yog Arduino's millis () pom qhov qhia no Android mobile thiab ntes nws rau
Chaw Ua Si Chaw Taws Teeb Chaw Tswj Hluav Taws Xob Wireless 3D Luam Tsheb: 7 Cov Kauj Ruam (nrog Duab)
Chaw Ua Si Chaw Taws Teeb Chaw Tswj Hluav Taws Xob Wireless 3D Luam Tsheb: Leej twg tsis nyiam twv txiaj? Sib tw thiab Sib ntaus hauv Ntiaj Teb Virtual ntawm Chaw Ua Si thiab Xbox !! Yog li, coj qhov kev lom zem rau lub neej tiag tiag Kuv tau ua Cov Lus Qhia no uas kuv yuav qhia koj li cas koj tuaj yeem siv ib qho Chaw Ua Si Chaw Taws Teeb Chaw Taws Teeb (Wired
Qhov Sib Txawv Ntawm Lub Rooj Sib Tham Lub Rooj Sib Tham Lub Hwj Huam!: 6 Kauj Ruam (nrog Duab)
Qhov Sib Txawv Ntawm Lub Rooj Sib Tham Bench Power Supply!: Koj puas tau tsim koj qhov haujlwm tshiab thiab tuav rov qab los ntawm qhov koj tsis muaj kev tswj hwm koj li peev txheej? Zoo, qhov no yog qhov haujlwm rau koj! Hnub no kuv yuav qhia koj yuav ua li cas thiaj tsim tau lub rooj zaum hauv lub rooj zaum ua haujlwm tau zoo rau qhov pheej yig heev! Kuv tau ua qhov no tag nrho
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