Hey guys, this is my first post here and I really hope that you can help me.
I recently bought an OLED-Display for my Arduino Nano and it seems to work fine. I managed to display text and graphics, and now I'm trying to connect the display with another program that plays music via a speaker.
That means that I'm implementing a screen where the three different options for songs to choose from is shown, which works just fine. (I have written a function menu() for that)
But now, I want the user to choose a song by pressing two buttons. One is for navigating and the other is for actually selecting the song.
The problem is that I didn't even get to the selecting-part. I have written three functions [p1(), p2() and p3()] that display a dot on the left side of each song, so that the user knows which song will be played if he pushes the select button.
Everything works fine, except for the navigation-dot that should be moving down each time the users is pressing the first button. Every time I press the button, it starts to move extremely fast through all of the options, although I only want it to move one option and then stop there until I press the button again.
I have already tried several different methods, but they don't seem to work, the dot is either moving as described or not at all.
Here is the relevant part of the code: (taster = button, zustand = state)
void loop() {
display.setTextColor(WHITE);
display.setTextSize(1);
tasterZustand4 = digitalRead(taster4);
tasterZustand5 = digitalRead(taster5);
menu();
for (int i = 0; i <= 2 && tasterZustand4 == LOW; ++i) {
tasterZustand4 = digitalRead(taster4);
tasterZustand5 = digitalRead(taster5);
if (i == 0) {
display.clearDisplay();
menu();
p1();
}
else if (i == 1) {
display.clearDisplay();
menu();
p2();
}
else if (i == 2) {
display.clearDisplay();
menu();
p3();
}
tasterZustand4 = digitalRead(taster4);
// while (tasterZustand4 == LOW) {} //dot isn't moving at all if this is active
}
display.display();
}