if (buttonPushCounter % 4 == 0)
{
digitalWrite(ledPin_wht_dim, LOW);
digitalWrite(ledPin_wht_bright, LOW);
}
else
{
digitalWrite(ledPin_wht_dim, LOW);
digitalWrite(ledPin_wht_bright, LOW);
}
If the button push counter value is 0, turn both lights off. Otherwise, turn both lights off.
I think I missed something there.
if (buttonPushCounter % 4 == 0)
if (buttonPushCounter % 4 == 1)
if (buttonPushCounter % 4 == 2)
if (buttonPushCounter % 4 == 3)
Only one of these conditions can be true. You could use a switch statement, instead.
switch(buttonPushCounter % 4)
{
case 0:
// Do something
break;
case 1:
// Do something
break;
case 2:
// Do something
break;
case 3:
// Do something
break;
}
I think, though, that the fundamental problem is that you don't know how to code.
Start with a simple sketch:
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.println("Hey, there...");
delay(1000);
}
Upload this, open the serial monitor window, and verify that it works.
Then, add code to detect if the button was pushed. Just print "Pressed" or "Not pressed".
Upload, and verify that it works. Then, add the code to compare the current state to the previous state, and only print something when the state changes. Verify.
Then, add the button press counting code. Print the number of times the button was pressed, when the button is pressed. Verify.
Then, create a new sketch to test the operation of the LEDs. Write some code to fade the LEDs like you want to have happen for one button press. Verify that that works.
Then, write some code to fade the LEDs like you want to have happen for two button presses. Verify.
Then, for 3 and for 4. Verify after each addition.
When the LED fading is working, merge the two scripts. Since you know that each one works independently, and you know what each part does, merging should be pretty easy.
If you want to just skip to the chase, though, analyze this code, and explain what it is doing:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
// sets the value (range from 0 to 255):
analogWrite(ledPin_wht_dim, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);