This shows you the differences between two versions of the page.
pm:prj2024:vstoica:adelin_costin.popa [2024/05/05 23:47] adelin_costin.popa [Descriere generală] |
pm:prj2024:vstoica:adelin_costin.popa [2024/05/23 23:43] (current) adelin_costin.popa [Software Design] |
||
---|---|---|---|
Line 9: | Line 9: | ||
===== Descriere generală ===== | ===== Descriere generală ===== | ||
+ | {{ :pm:prj2024:vstoica:tuneduino.png?nolink | }} | ||
===== Hardware Design ===== | ===== Hardware Design ===== | ||
- | <note tip> | + | * 1 x Arduino Uno |
- | Aici puneţi tot ce ţine de hardware design: | + | * 4 x butoane |
- | * listă de piese | + | * 1 x modul pentru SD card |
- | * scheme electrice (se pot lua şi de pe Internet şi din datasheet-uri, e.g. http://www.captain.at/electronic-atmega16-mmc-schematic.png) | + | * 1 x SD card |
- | * diagrame de semnal | + | * 1 x breadboard |
- | * rezultatele simulării | + | * 1 x speaker |
- | </note> | + | |
+ | |||
+ | === Schema electrica === | ||
+ | {{ :pm:prj2024:vstoica:tuneduino-electrical-scheme.jpg?nolink&600 | }} | ||
+ | |||
+ | === Montaj === | ||
+ | {{ :pm:prj2024:vstoica:tuneduino-poc.jpg?nolink&400 | }} | ||
===== Software Design ===== | ===== Software Design ===== | ||
- | <note tip> | + | * Arduino IDE |
- | Descrierea codului aplicaţiei (firmware): | + | * DFRobotDFPlayerMini (pentru player-ul de muzica), SevSeg (pentru operarea cu display-ul pe 7 segmente) |
- | * mediu de dezvoltare (if any) (e.g. AVR Studio, CodeVisionAVR) | + | |
- | * librării şi surse 3rd-party (e.g. Procyon AVRlib) | + | |
- | * algoritmi şi structuri pe care plănuiţi să le implementaţi | + | void loop() |
- | * (etapa 3) surse şi funcţii implementate | + | { |
- | </note> | + | unsigned long currentMillis = millis(); |
+ | unsigned long duration; | ||
+ | if (in_menu) { | ||
+ | buttonState = digitalRead(mainbutton); | ||
+ | |||
+ | if (buttonState != lastButtonState) { // button state changed | ||
+ | updateState(); | ||
+ | } | ||
+ | |||
+ | if (startPressed == -1 && endPressed == -1) { | ||
+ | if (longPress) { | ||
+ | in_menu = false; | ||
+ | playing = true; | ||
+ | myDFPlayer.play(song_number); // Play song | ||
+ | if (myDFPlayer.available()) { | ||
+ | printDetail(myDFPlayer.readType(), myDFPlayer.read()); //Print the detail message from DFPlayer to handle different errors and states. | ||
+ | } | ||
+ | } else { | ||
+ | if (currentMillis - previousMillis >= interval) { | ||
+ | previousMillis = currentMillis; | ||
+ | song_number++; | ||
+ | if (song_number > 9) { | ||
+ | song_number = 1; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | sevseg.setNumber(song_number); | ||
+ | } | ||
+ | startPressed = 0; | ||
+ | endPressed = 0; | ||
+ | } | ||
+ | |||
+ | lastButtonState = buttonState; | ||
+ | } else if (playing) { | ||
+ | sevseg.blank(); | ||
+ | if (currentMillis - previousMillis >= interval) { | ||
+ | previousMillis = currentMillis; | ||
+ | safety_check = true; | ||
+ | } | ||
+ | |||
+ | if (digitalRead(mainbutton) == LOW && safety_check) { | ||
+ | playing = false; | ||
+ | myDFPlayer.stop(); // Stop playing | ||
+ | safety_check = false; | ||
+ | } | ||
+ | } else if (!playing && !in_menu) { | ||
+ | sevseg.setChars("P"); | ||
+ | |||
+ | if (currentMillis - previousMillis >= interval) { | ||
+ | previousMillis = currentMillis; | ||
+ | safety_check = true; | ||
+ | } | ||
+ | |||
+ | if (digitalRead(mainbutton) == LOW && safety_check) { | ||
+ | playing = true; | ||
+ | // myDFPlayer.play(song_number); // Resume playing | ||
+ | myDFPlayer.next(); | ||
+ | if (myDFPlayer.available()) { | ||
+ | printDetail(myDFPlayer.readType(), myDFPlayer.read()); //Print the detail message from DFPlayer to handle different errors and states. | ||
+ | } | ||
+ | sevseg.blank(); | ||
+ | safety_check = false; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | sevseg.refreshDisplay(); | ||
+ | } | ||
===== Rezultate Obţinute ===== | ===== Rezultate Obţinute ===== |