Hi, I want to add another pushbutton to control the speed of the motor to make it go faster on pin 4 how can i do that? This is arduino on tinkercad
int pinButton = 8;
int LED = 2;
int stateLED = LOW;
int stateButton;
int previous = LOW;
long time = 0;
long debounce = 200;
void setup() {
pinMode(pinButton, INPUT);
pinMode(LED, OUTPUT);
}
void loop() {
stateButton = digitalRead(pinButton);
if(stateButton == HIGH && previous == LOW && millis() - time > debounce) {
if(stateLED == HIGH){
stateLED = LOW;
} else {
stateLED = HIGH;
}
time = millis();
}
digitalWrite(LED, stateLED);
previous == stateButton;
}