Cov txheej txheem:

"Ninja Dollar" Game rau Arduino: 3 Kauj Ruam
"Ninja Dollar" Game rau Arduino: 3 Kauj Ruam

Video: "Ninja Dollar" Game rau Arduino: 3 Kauj Ruam

Video:
Video: It Became Unliveable! ~ Abandoned Home Of The Spenser's In The USA 2024, Hlis ntuj nqeg
Anonim
Duab
Duab

Lwm qhov vis dis aus game rau arduino.it yog qhov kev ua si zoo tshaj plaws tshaj li qhov kuv tshaj tawm zaum kawg. Vim li cas nws thiaj li nyuaj dua li lwm yam? Nws nyuaj dua vim tias qhov no tuaj yeem dhia thiab tua thiab muaj lub suab nrov thiab cov ntsiab lus tshiab txuas ntxiv.

Khoom siv

  1. Arduino.
  2. Cov qhob cij
  3. jumper cov xov hlau
  4. Liab LED
  5. 2 cov nyees khawm
  6. 2 10k ohm resistors
  7. 2 220R resistors.
  8. Super ci Blue LED.
  9. piezo buzzer: cov
  10. 16*2 LCD zaub

Kauj Ruam 1: Txuas Txhua Yam Ua Ke

Txuas Txhua Yam Ua Ke
Txuas Txhua Yam Ua Ke

Tam sim no koj yuav tsum xaim txhua yam

Kauj Ruam 2: Yuav Ua Li Cas:

  1. Qhib lub arduino.
  2. LCD yuav tsum luam tawm: "qhov kev ua si pib hauv" thiab suav rov qab.
  3. Nias ib qho ntawm cov nyees khawm kom dhia thiab lwm yam los tua.
  4. txhua qhov thaiv uas koj dhia koj yeej ib lub ntsiab lus thiab txhua * uas koj ntes tau muab rau koj 5 cov ntsiab lus.
  5. Thaum koj muaj 50 cov ntsiab lus lossis siab dua koj yeej

Kauj Ruam 3: Txoj Cai

// este jogo e muito interessante e ao mesmo tempo irritante e frustante mas muito divertido.

#suav nrog

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;

const int buttonPin1 = 1; const int buttonPin2 = 6; const int buzzer = 7; unsigned ntev pts = 0; // teeb tsa buttonstates bool buttonState1 = 0; bool buttonState2 = 0; // random tus lej rau txoj haujlwm ntawm cov teeb meem int randomNums [6]; // random tus lej rau tus naj npawb ntawm cov teeb meem int randomNum = 0; // random tus lej rau txoj haujlwm ntawm pts int randomNums1 [3]; // random tus lej rau tus lej pts int randomNum1 = 0; // pib ncua sijhawm, uas txo qis maj mam kos npe rau myDelay = 500; // ua qhov boolean no txhawm rau txheeb xyuas yog tias khawm 2 raug nias vim tias yog nws tau nias ib zaug hauv thawj zaug rau lub voj kuv xav tau teeb meem tsis txhob sau kom txog thaum kawg ntawm nws bool temp = 0; // qhov sib txawv no khaws cov haujlwm ntawm tus tub rog thaum nws tua. tuaj yeem muaj 16 txoj haujlwm vim tias tus tub rog muaj 16 txoj haujlwm. koj tempI [16]; // Kuv siv cov boolean no los xyuas yog tias lub ntsiab lus raug catched bool temp1 = 0;

// siv qhov sib txawv no los khaws txoj haujlwm ntawm lub ntsiab lus. nws yuav tsum yog thiab khaws cia txoj haujlwm ntawm txhua lub ntsiab lus hauv ib qho rov ua dua ntawm thawj rau lub voj. yog tias nws khaws cia tsuas yog ib txoj haujlwm, tom qab ntawv "qub" yuav rov qab los hauv qhov rov ua dua tshiab

koj tempI1 [3]; // siv qhov sib txawv no kom muaj tus lej txhaj tshuaj ntawm tus tub rog, uas tseem yog qhov ntev ntawm ib qho array tempI int button2IsPressed = 0; LiquidCrystal lcd (rs, en, d4, d5, d6, d7);

void teeb tsa () {

// teeb tsa LCD tus lej ntawm kab thiab kab: lcd.begin (16, 2); // teeb tsa hom khawm hom pinMode (buttonPin1, INPUT); pinMode (buttonPin2, INPUT); tus pinMode (buzzer, OUTPUT); lcd.setCursor (4, 0); lcd.print ("THE GAME"); lcd.setCursor (2, 1); lcd.print ("STARTS IN"); lcd.print ("5"); ncua (1000); lcd.setCursor (12, 1); lcd.print ("4"); ncua (1000); lcd.setCursor (12, 1); lcd.print ("3"); ncua (1000); lcd.setCursor (12, 1); lcd.print ("2"); ncua (1000); lcd.setCursor (12, 1); lcd.print ("1"); ncua (1000); lcd.clear ();

}

void voj () {

ntawm no:

randomNum = random (5);

rau (int i = 0; i9 && pts19 && pts29 && pts = 50) {pts = 0; myDelay = 500; lcd.clear (); lcd.setCursor (5, 0); lcd.print ("VICTORY"); suab (buzzer, 262); ncua (200); suab nrov (buzzer, 330); ncua (200); suab nrov (buzzer, 392); ncua (100); suab nrov (buzzer, 330); ncua (100); suab nrov (buzzer, 392); ncua (100); suab nrov (buzzer, 523); ncua (200); noTone (buzzer); ncua (3000); lcd.clear (); tuaj ntawm no; } lwm tus lcd.setCursor (15, 0); lcd.print (pts); buttonState1 = digitalRead (buttonPin1); buttonState2 = digitalRead (buttonPin2); // teeb tsa teeb meem yog tias tus tub rog tsis tua lossis nws tua tab sis nws tseem dhia yog (! temp) {rau (int j = 0; jrandomNums [j]) {lcd.setCursor (randomNums [j], 1); lcd.print ("#"); }

}

}

// teeb tsa pts

yog (! temp1) {rau (int j = 0; j

}

Pom zoo: