Another Buzz Wire Game!
Old fashion game with more electronics
Components and supplies
1
Arduino Nano R3
1
Breadboard (generic)
1
Buzzer
1
RGB Backlight LCD - 16x2
1
Jumper wires (generic)
Apps and platforms
1
Arduino IDE
Project description
Code
Arduino IDE Codes
arduino
1#include <LiquidCrystal.h> 2 3const int rs = 12, en = 11, d4 = 6, d5 = 5, d6 = 4, d7 = 3; 4LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 5int t; 6int told; 7int hak = 3; 8bool flag1 = false; 9unsigned long eskiZaman; 10 11void setup() { 12 lcd.begin(16, 2); 13 lcd.print("Istek Bilim!"); 14 lcd.setCursor(0, 1); 15 lcd.print("Tel Oyunu"); 16 delay(1000); 17 lcd.clear(); 18 pinMode(2, INPUT_PULLUP); 19} 20 21void loop() { 22 zaman(); 23 puanKontrol(); 24 25 if (flag1 == false) { 26 lcd.setCursor(0, 0); 27 lcd.print("Istek Bilim! "); 28 29 for (int x = 0; x < 16; x++) { 30 31 lcd.setCursor(x, 1); 32 lcd.print(">"); 33 delay(70); 34 35 if (digitalRead(2) == LOW) { 36 break; 37 } 38 } 39 40 for (int x = 0; x < 16; x++) { 41 42 lcd.setCursor(x, 1); 43 lcd.print(" "); 44 delay(70); 45 46 if (digitalRead(2) == LOW) { 47 break; 48 } 49 } 50 51 if (digitalRead(2) == LOW) { 52 flag1 = true; 53 lcd.clear(); 54 eskiZaman = (millis() / 1000); 55 hak = 3; 56 for (int i = 0; i < 16; i++) { 57 tone(9, 50 * i, 525); 58 delay(25); 59 noTone(9); 60 } 61 } 62 } else { 63 if (t > 0 && hak > 0) { 64 lcd.setCursor(0, 1); 65 lcd.print("Kalan Hak:"); 66 lcd.setCursor(11, 1); 67 lcd.print(hak); 68 lcd.setCursor(0, 0); 69 lcd.print("Kalan Sure:"); 70 lcd.setCursor(12, 0); 71 lcd.print(t); 72 if (t != told) { 73 lcd.clear(); 74 told = t; 75 } 76 77 if (t < 5) { 78 tone(9, 880 / t, 200); 79 } 80 81 } else { 82 83 if (t > 0) { 84 lcd.setCursor(0, 0); 85 lcd.print("Hakkin Kalmadi"); 86 lcd.setCursor(0, 1); 87 lcd.print("Tekrar Dene..."); 88 for (int i = 4; i > 0; i--) { 89 tone(9, 50 * i, 200); 90 delay(200); 91 noTone(9); 92 } 93 delay(5000); 94 flag1 = false; 95 } else { 96 lcd.setCursor(0, 0); 97 lcd.print("Zaman Doldu..."); 98 lcd.setCursor(0, 1); 99 lcd.print("Tekrar Dene..."); 100 for (int i = 4; i > 0; i--) { 101 tone(9, 50 * i, 200); 102 delay(200); 103 noTone(9); 104 } 105 delay(5000); 106 flag1 = false; 107 } 108 } 109 } 110} 111 112void zaman() { 113 t = (eskiZaman + 30) - (millis() / 1000); 114 115} 116 117void puanKontrol() { 118 if (digitalRead(2) == LOW) { 119 hak--; 120 if (hak > 0) { 121 tone(9, 600 / hak, 500); 122 delay(500); 123 noTone(9); 124 } 125 } 126 127}
Comments
Only logged in users can leave comments