PROBLEM CODE

Hi everyone,

We're having a problem =(, we need to make this assignment : Arduino - 4 verschillende animaties met buttonknop on Vimeo
We have the setup , but we only need the code.
ledPin= 12
ledPin= 11
ledPin= 10
ledPin= 9

buttonPin = 2

Please help us!!!! =(
thank u

What have you got so far?

int buttonPin = 2;
int ledEen = 9;
int ledTwee = 10;
int ledDrie = 11;
int ledVier = 12;

int buttonState = 0;
int buttonCounter = 0

void setup() {
pinMode(ledEen, OUTPUT);
pinMode(ledTwee, OUTPUT);
pinMode(ledDrie, OUTPUT);
pinMode(ledVier, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(potPin,INPUT);
}

void loop() {
buttonState = digitalRead(buttonPin);

if(buttonState == HIGH)}

buttonCounter = buttonCounter +1;
}

if(buttonCounter == 0){
// animatie
}

if(buttonCounter == 1){

}

//reset counter
if(buttonCounter >5){
buttonCounter = 0;
}

Perhaps you noticed in the video that the pattern displayed by the LEDs did not change AS THE SWITCH WAS HELD DOWN.

It changed only when the switch was pressed and released.

Therefore, the first thing you need to do is make things happen, like counting, only when the state of the switch changes. You'll need to record the previous state of the switch at the end of loop(), and read the current state at the beginning of loop(). In between, you determine if the state has changed, and if so, whether it changed to pressed or released.

Once you have the counting working, changing how the Arduino manipulates the LEDs as the count changes, is trivial.

Hint: Forget about using delay() for anything.