Giter VIP home page Giter VIP logo

Comments (3)

robsoncouto avatar robsoncouto commented on July 21, 2024

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.

PedroVillasBoas avatar PedroVillasBoas commented on July 21, 2024

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.

robsoncouto avatar robsoncouto commented on July 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.