Help with speed controlled fan (pot) keyestudio components (INA and INB) fan type

something like that?

int INA = 9; //pin connected to INA
int INB = 10; // pin connected to INB
int button = 11; // pin connected to button
int button_presses = 0; //button press counter


void setup() {
  //declare pin modes
  pinMode(INA,OUTPUT); 
  pinMode(INB,OUTPUT);
  pinMode(button,INPUT);
}

void loop() {
  // raise button counter if button pressed
  if(digitalRead(button) == 1){
    button_presses ++;
    delay(10)
  }


  //turn the fan right if button has been pressed 1 time
  if(button_presses == 1){
    analogWrite(INA,255);
    digitalWrite(INB,0); 
  }

  //turn the fan left if button has been pressed 2 times
  if(button_presses == 2){
    analogWrite(INB,255);
    digitalWrite(INA,0); 
  }

  //turn fan off if button has been pressed 3 times
  if(button_presses == 3){
    digitalWrite(INA,0);
    digitalWrite(INB,0); 
  }

  //reset button counter
  if(button_presses >= 3){
    button_presses = 0;
  }

}

No. Did you try it?

The pushbutton will be seen many many times per second, and when pressed button_presses will skitter around and around, where it stops is nobody's guess.

So unless you were going for a frustrating game, no.

How do I know?

a7

Aorry forgot a delay(10) after button_presses++
I will be editing my previous code

Let me know if anything else is wrong, but i will not ne responding shortly, as it is 3am in my country and i will be sleeping

Did you test your fix? That really won't help.

a7

I'm sure @sebsupreme and @shelleyamundson1 will mention you when they have their presentation :innocent:

Yes, thank you all for your help, and I will be sure to mention you all! :+1:

(INA and INB keyestudio module) fan controlled by potentiometer

Isn't this just the same as

Why create a new topic?

That's 3 times crossposting the same stuff now.

https://forum.arduino.cc/t/help-with-fan-motor-keyestudio-components-controlled-by-switch-case-button-code/1349834

https://forum.arduino.cc/t/ina-and-inb-keyestudio-module-fan-controlled-by-potentiometer-help-plsss/1352082

@sebsupreme ,

Your three topics on the same or similar subject have been merged.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

I'm sorry everybody for disregard to the rules of the forum, I've taken time to read through the rules and now know how to maintain peace within the forum.