control PWM with push button and counter???

I'm attempting to make a dimmer switch by using a tactile switch and a counter function. I'm pretty sure the code is the issue.

basically every time the button is pressed then it changes PWM setting. I'm not getting any light action out of my LED's...they are off. (I know they work because when I used digitalWrite instead of analogWrite they came on... obviously the dimmer function doesn't work like that)

Could I get some guidance perhaps? do I need to use a FOR statement?

byte dimmerSwitch = 9; // temporary switch for counter. counter is pwm for led dimmer
byte dimmerCount;            // track button press
byte dimmerValue;            // set PWM with counter 0-3
byte ledRred = 10;      // red LED right side
byte ledRyellow = 11;   // yellow LED right side



void setup() {
  // put your setup code here, to run once:
  pinMode(dimmerSwitch,INPUT_PULLUP);
  pinMode(ledRred,OUTPUT);
  pinMode(ledRyellow,OUTPUT);
  dimmerCount = 3;
}

void loop() {
  // put your main code here, to run repeatedly:

if (digitalRead,dimmerSwitch == LOW){
    dimmerCount++;
}
else if (dimmerCount = 4){
    dimmerCount = 0;
}
else if (dimmerCount = 0){
  dimmerValue = 75;
}
else if (dimmerCount = 1){
  dimmerValue = 130;
}
else if (dimmerCount = 2){
  dimmerValue = 200;
}
else if (dimmerCount = 3){
  dimmerValue = 250;
}

analogWrite(ledRred,dimmerValue);
analogWrite(ledRyellow,dimmerValue);

}

if (digitalRead,dimmerSwitch == LOW) Interesting arrangement of keywords. What does it do?

if (dimmerCount = 4)Oh dear.

if (digitalRead (dimmerSwitch) == LOW) // like this???

Better, yes

GrooveFlotilla: if (dimmerCount = 4)Oh dear.

do you have a suggestion for this? I am fairly new to coding. I dont know what to do with my hands....

Take a close look at reply 3

I took the ELSE out and the LED's are on, now it seems like the counter is not working, there is no dimming action

SOLVED!!!

had a short to ground and it was causing the dimmer to shift faster than I could see... I replaced the switch and added a small delay, seems to be working so far

byte dimmerSwitch = 9; // temporary switch for counter. counter is pwm for led dimmer
byte dimmerCount;            // track button press
int dimmerValue;            // set PWM with counter 0-3
byte ledRred = 10;      // red LED right side
byte ledRyellow = 11;   // yellow LED right side



void setup() {
  // put your setup code here, to run once:
  pinMode(dimmerSwitch,INPUT_PULLUP);
  pinMode(ledRred,OUTPUT);
  pinMode(ledRyellow,OUTPUT);
  dimmerCount = 3;
}

void loop() {
  // put your main code here, to run repeatedly:
if (dimmerCount == 4){
    dimmerCount = 0;
}
if (dimmerCount == 0){
  dimmerValue = 20;
}
if (dimmerCount == 1){
  dimmerValue = 80;
}
if (dimmerCount == 2){
  dimmerValue = 170;
}
if (dimmerCount == 3){
  dimmerValue = 250;
}
if (digitalRead(dimmerSwitch) == LOW){
    dimmerCount++; 

}
analogWrite(ledRred,dimmerValue);
analogWrite(ledRyellow,dimmerValue);

delay(200);
}