so i couldnt figure out how to do it like you stated.
i was able to do it by commanding if on for 18ms and off for 2 ms (10ms for test purposes)
if (currentGear == 2 || currentGear == 3 || currentGear == 4);
digitalWrite(Sol32, HIGH); // turn the LED on (HIGH is the voltage level)
delay(18); // wait for a second
digitalWrite(Sol32, LOW); // turn the LED off by making the voltage LOW
delay(10);
now the issue when i go from 2nd to 3rd and 3rd to 4th, it turns the led off for the half second delay i have built into the button state change poll. so, when i command 2nd the led should be flashing. when i command 3rd the led should be flashing. but there is a half second pause where it is not flashing during gear change. i need it to stay flashing
here is a visual of the delay i have set in place. i have the delay there so that a button press only changes one gear unless the button is held for longer than half a second
if (RbuttonState != RlastButtonState) {
if (RbuttonState == 1 && currentGear == 1) {
currentGear = 2;
RlastButtonState = 1;
Serial.println("2 on");
delay(500);
the leds in my switch case will stay lit without going out for the half second if the pin state is common between the case values. . bellow is my switch case for gear change requirements.
switch(currentGear) {
case 1:
digitalWrite(ledPin1,HIGH); // turns on 1st gear feedback LED
digitalWrite(SolA,HIGH); // SolA on
digitalWrite(SolB,HIGH); // SolB on
break;
case 2:
digitalWrite(ledPin2,HIGH); // turns on 2nd gear feedback LED
digitalWrite(SolA,LOW); // SolA off
digitalWrite(SolB,HIGH); // SolB on
break;
case 3:
digitalWrite(ledPin2,HIGH); // turns on 3rd gear feedback LED
digitalWrite(SolA,LOW); // SolA off
digitalWrite(SolB,LOW); // SolB off
break;
case 4:
digitalWrite(ledPin2,HIGH); // turns on 4th gear feedback LED
digitalWrite(SolA,HIGH); // SolA on
digitalWrite(SolB,LOW); // SolB off
break;
if i need to post the entire code let me know
cliffnotes: led that needs to be PWM needsd to remain on duffing switch case changes. LEds that are common between switch case changes stay lit without going out why cant the PWM one?