This shows you the differences between two versions of the page.
pm:prj2024:vstoica:adelin_costin.popa [2024/05/16 23:45] adelin_costin.popa [Hardware Design] |
pm:prj2024:vstoica:adelin_costin.popa [2024/05/23 23:43] (current) adelin_costin.popa [Software Design] |
||
---|---|---|---|
Line 23: | Line 23: | ||
{{ :pm:prj2024:vstoica:tuneduino-electrical-scheme.jpg?nolink&600 | }} | {{ :pm:prj2024:vstoica:tuneduino-electrical-scheme.jpg?nolink&600 | }} | ||
- | === Aranjament fizic === | + | === Montaj === |
{{ :pm:prj2024:vstoica:tuneduino-poc.jpg?nolink&400 | }} | {{ :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 ===== |