If Poti < 560 {melody}

How? ..........................................

You can start by reading the sticky post at the top of the forum and learning how to properly post your code. It will help others help you. Please read it, then go back and edit your code and make it look like easily copiable code.

After that, check out the several things at the same time to learn how to break your code up do do multiple things. Currently, if any of the buttons are pressed, you play that specific tone. Maybe start by writing down exactly what you want the code to do.

Also, all y our code like this

  pinMode(C, INPUT);
  digitalWrite(C, HIGH);

is better written as

  pinMode(C, INPUT_PULLUP);

exchange the while() against an if().
I gues that would work better.

You get the current position of the pot with
`int potPosition = analogRead(poti);'
If that value changes, play the melody. To calculate if it changes, store the previous value and compare the new position to the previous position.

Dear helpers, with your willingness to help you support people who do not want to read !!! There are hundreds of these clues! The moderator should once issue a guideline that such people must not be helped until they can / want to read. Otherwise the Arduino forum will become more and more a collection of the same "nice tips".

1 Like

... or at least that, by reading the code, is able to do something useful, and, if not (well mostly, as people ask questions mostly here because something is NOT working), the author has a good description of what is going wrong. And what the code is supposed to do.

Here it looks already like rubbish, and it is asked to extend the functionality ... ah, no, ...

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.