This shows you the differences between two versions of the page.
pm:prj2021:apredescu:wirebuzz [2021/06/04 14:43] vladislav.stratila [Bibliografie/Resurse] |
pm:prj2021:apredescu:wirebuzz [2021/06/04 14:58] (current) vladislav.stratila [Rezultate Obținute] |
||
---|---|---|---|
Line 50: | Line 50: | ||
In cazul in care pinul 3(end) trece in starea LOW iar pinul 2(start) ramane in starea HIGH inseamna ca firul a atins partea de jos a diodei si runda a fost castigata.Se reda un sound diferit de cele anterioare si se afiseaza pe LCD mesajul "You Win The Game". | In cazul in care pinul 3(end) trece in starea LOW iar pinul 2(start) ramane in starea HIGH inseamna ca firul a atins partea de jos a diodei si runda a fost castigata.Se reda un sound diferit de cele anterioare si se afiseaza pe LCD mesajul "You Win The Game". | ||
- | Code: | ||
- | |||
- | <code>#include <LiquidCrystal.h> | ||
- | const int RS = 8; | ||
- | const int EN = 9; | ||
- | const int d4 = 4; | ||
- | const int d5 = 5; | ||
- | const int d6 = 6; | ||
- | const int d7 = 7; | ||
- | |||
- | LiquidCrystal lcd( RS, EN, d4, d5, d6, d7); | ||
- | |||
- | //Pins for start and end | ||
- | const int startPin = 2; | ||
- | const int endPin = 3; | ||
- | |||
- | //Buzzer | ||
- | const int buzzer = 11; | ||
- | int start, end_; | ||
- | |||
- | //Number of contacts | ||
- | int contacts = 0; | ||
- | |||
- | int x = 100; | ||
- | |||
- | void setup(void) | ||
- | { | ||
- | Serial.begin(9600); | ||
- | lcd.begin(16,2); | ||
- | lcd.clear(); | ||
- | pinMode(buzzer, OUTPUT); | ||
- | pinMode(startPin, INPUT_PULLUP); | ||
- | pinMode(endPin, INPUT_PULLUP); | ||
- | lcd.setCursor(0,0); | ||
- | lcd.print("Contacts:"); | ||
- | } | ||
- | void loop(void) | ||
- | { | ||
- | lcd.setCursor(9,0); | ||
- | lcd.print(contacts); | ||
- | start = digitalRead(startPin); | ||
- | end_= digitalRead(endPin); | ||
- | //Check for loose | ||
- | if (contacts >= 10) { | ||
- | lcd.setCursor(0,6); | ||
- | lcd.print("Game Over"); | ||
- | x = analogRead (0); | ||
- | delay(500); | ||
- | tone(buzzer, 500, 200); | ||
- | delay(200); | ||
- | tone(buzzer, 1200, 200); | ||
- | delay(200); | ||
- | tone(buzzer, 300, 200); | ||
- | delay(200); | ||
- | tone(buzzer, 1000, 200); | ||
- | delay(200); | ||
- | tone(buzzer, 400, 200); | ||
- | delay(200); | ||
- | tone(buzzer, 1100, 200); | ||
- | delay(1000); | ||
- | if (x < 60) { | ||
- | lcd.setCursor(0,6); | ||
- | lcd.print(" "); | ||
- | lcd.setCursor(9,0); | ||
- | lcd.print(" "); | ||
- | contacts = 0; | ||
- | x = 100; | ||
- | } | ||
- | } | ||
- | //Check for contact | ||
- | if (start == LOW and end_ == LOW) { | ||
- | if (contacts < 10) { | ||
- | tone(buzzer,1000); | ||
- | delay(300); | ||
- | noTone(buzzer); | ||
- | contacts++; | ||
- | } | ||
- | } | ||
- | | ||
- | //Check for finish | ||
- | if (start == HIGH and end_ == LOW) { | ||
- | if (contacts < 10) { | ||
- | lcd.setCursor(0,6); | ||
- | lcd.print("You WIN the Game"); | ||
- | tone(buzzer,500,200); | ||
- | delay(200); | ||
- | tone(buzzer,500,200); | ||
- | delay(200); | ||
- | tone(buzzer,500,200); | ||
- | delay(200); | ||
- | tone(buzzer,800,150); | ||
- | delay(150); | ||
- | tone(buzzer,500,500); | ||
- | delay(500); | ||
- | tone(buzzer,600,1000); | ||
- | delay(10000); | ||
- | lcd.setCursor(0,6); | ||
- | lcd.print(" "); | ||
- | lcd.setCursor(9,0); | ||
- | lcd.print(" "); | ||
- | contacts = 0; | ||
- | } | ||
- | } | ||
- | } </code> | ||
===== Rezultate Obținute ===== | ===== Rezultate Obținute ===== | ||
DEMO: https://www.youtube.com/watch?v=K5ur96gdY-g | DEMO: https://www.youtube.com/watch?v=K5ur96gdY-g | ||
Line 166: | Line 62: | ||
===== Concluzii ===== | ===== Concluzii ===== | ||
+ | Consider ca a fost un proiect foarte interesant, din care am avut multe de invatat, atat pe partea de hardware cat si pe cea de software si rezultatul este unul satisfacator. | ||
===== Download ===== | ===== Download ===== | ||
Documentația în format <html><a class="media mediafile mf_pdf" href="?do=export_pdf">PDF</a></html> | Documentația în format <html><a class="media mediafile mf_pdf" href="?do=export_pdf">PDF</a></html> | ||
+ | |||
+ | Codul sursa {{ | ||
+ | :pm:prj2021:apredescu:wirebuzzgame.zip|}} | ||
===== Jurnal ===== | ===== Jurnal ===== | ||
* 02.05.2021 - Introducere,lista piese | * 02.05.2021 - Introducere,lista piese | ||
Line 178: | Line 78: | ||
* https://create.arduino.cc/projecthub/SURYATEJA/use-a-buzzer-module-piezo-speaker-using-arduino-uno-89df45 | * https://create.arduino.cc/projecthub/SURYATEJA/use-a-buzzer-module-piezo-speaker-using-arduino-uno-89df45 | ||
* https://circuitdigest.com/microcontroller-proejcts/arduino-buzz-wire-game | * https://circuitdigest.com/microcontroller-proejcts/arduino-buzz-wire-game | ||
- | * |