Comments (3)
Hi Pedro,
That is happening because your music function (as the code in this repo) is blocking code. If you want to know more about the subject, try looking up "blocking vs non-blocking code". The Music() function will prevent the execution of the rest of the code (including reading buttons) until it is finished. So what you want to do is to let the music play "on the background" while alternating with other functions.
I already did that with my tetris on the gm328a project, so it should be an easy fix.
First have a look at the code for playing the nodes here
Then you just need to call the sound updating function every cycle like this:
void loop() {
soundTick(); //You can just change Music() to look like mine and call it instead.
//everything else
}
STILL, you don't want to use delay on the loop funcion. Since that will also block the rest of the code(even without Music() you take 2 seconds to read buttons again, that's "0.5Hz"). So you may want to use millis instead in your functions as well. The example BlinkWithouDelay may be helpful. Besides, why are you blinking the buzzer?? Anyways, Good luck!
Grande abraço!
Rob
from arduino-songs.
Rob,
First of all, thank you very much for the reply and sorry for the delay in giving a response!
I didn't understand Blinking buzzer, I just started with Arduino and I'm learning little by little! (If you could talk a little about the problem, I would be very happy!!)
I haven't made the suggestions you gave yet, but I will make them and come back here with an answer!
Again, thank you very much! I spent some time trying to decipher what was going on, but you gave me a path to follow!
////////////////////////////////////////////// Translation to portuguese bellow ! //////////////////////////////////////////////
Rob,
Primeiramente muito obrigado pelo resposta e perdão pela demora pra dar alguma posição!
Não entendi o Blinking buzzer, comecei a pouco com o arduino e estou aprendendo aos poucos! (Se puder dissertar um pouco sobre o problema, ficaria bem feliz!!)
Ainda não realizei as sugestões que você deu, mas irei realiza-las e volto aqui com uma resposta!
Novamente, muito obrigado! Passei algum tempo tentando decifrar o que estava acontecendo, mas você me deu uma grande luz!
from arduino-songs.
Oi Pedro
Não reparei no comentário devido a formatação do github hehe . O que eu chamei de blinking é ligar e desligar o pino do buzzer. Provavelemente seria melhor apagar de vez isso do seu código, deixando assim:
void loop() {
Music();
ButtonPressing();
}
from arduino-songs.
Related Issues (20)
- can any of these be used on the smart inventor-mega32_v2 HOT 1
- Any possibility to turn speak off during rest notes
- can you do among us drip
- How can I contribute to this repo?
- Please do Jurassic Park theme.
- Tetris is wrong
- add im blue HOT 1
- Created Arduino-Music library based off your examples.
- Add Megalovania(Undertale theme) *Look in comment for code*
- Could you make reach for the stars? (The one from sonic colors)
- podrian hacer una de caballeros del zodiaco la saga de ades?
- add another song :) HOT 3
- This nice music on ESP32
- The Godfather theme not according to sheet. Wrong note. HOT 1
- Songs are unlicensed
- Generator for songs
- Non-Blocking Code HOT 1
- Can you add Transformers G1 transition sound effect please i need it for a project HOT 1
- could you please code Treachery by Shiro Sagisu?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino-songs.