I have an int array of melodies. If i press the button it plays the whole song but if i put a break after the delay, than it just reset the i. How do i make it so that only after another button-press it continues? (i'm still a newbie at this sorry and thanks in advance)
int buttonPin = 12;
void setup()
{
// put your setup code here, to run once:
pinMode(buttonPin, INPUT);
}
void loop()
{
// put your main code here, to run repeatedly:
int buttonState = digitalRead(buttonPin);
for(int i = 0; i < sizeof(mariomelody); i++)
{
if(buttonState == HIGH)
{
tone(8, mariomelody[i], 70);
delay();
}
}
}
digitalWrite(buttonPin, LOW);in setup. also try putting it before if statement.