[![Here is the wiring ][1]][1] [1]: https://i.sstatic.net/sBk8J.jpg
The image is as clear as I can make it.
#include <Servo.h>
Servo servo1;
//------------------------
// White LED's:
int wL1 = 3;
int wL2 = 4;
int wL3 = 5;
int wL4 = 6;
int wL5 = 7;
//------------------------
// Red LED's:
int rL1 = 8;
//------------------------
// Buttons:
int wLbutton = 2;
int wLreading;
int wL1state = HIGH;
int wL2state = HIGH;
int wL3state = HIGH;
int wL4state = HIGH;
int wL5state = HIGH;
int wLprevious = LOW;
int servoButton = 1;
int servoState = false;
int servoReading;
int servoPrevious = LOW;
//--------------------------
// Fading:
int brightness = 0;
int fade = 1;
//--------------------------
// Delays:
long time = 0;
long time2 = 0;
long debounce = 100;
unsigned long previousMillis = 0;
const long interval = 1000;
//--------------------------
// Setup ======================================================================================================================================
void setup()
{
pinMode(wL1,OUTPUT); // White LED's
pinMode(wL2,OUTPUT);
pinMode(wL3,OUTPUT);
pinMode(wL4,OUTPUT);
pinMode(wL5,OUTPUT);
pinMode(rL1,OUTPUT); // Red LED's
pinMode(wLbutton, INPUT); // Buttons
pinMode(servoButton, INPUT);
servo1.attach(10);
servo1.write(90); // Servo
if (wL1state = HIGH)
{
wL1state = LOW; // Set the state of the all White LED buttons to low at the beginning of the circuit (this doesnt run after the first time).
wL2state = LOW;
wL3state = LOW;
wL4state = LOW;
wL5state = LOW;
}
}
// Loop =========================================================================================================================================
void loop() {
// White LED Button -----------------------------------------------------------------------------------------------------------------------------
wLreading = digitalRead(wLbutton); // Read the state of the White LED Button
if (wLreading == HIGH && wLprevious == LOW && millis() - time > debounce) // If the button is different state from last reading and ignores noise
{
if (wL1state == HIGH) // If the current button state of the White LED button is high
{
wL1state = LOW; // Set the state of the all White LED buttons to low
wL2state = LOW;
wL3state = LOW;
wL4state = LOW;
wL5state = LOW;
}
else {
wL1state = HIGH; // Otherwise, set the state of the White LED button to high
}
time = millis(); // Set the last time the button was pressed to the current time
}
digitalWrite(wL1,wL1state);
digitalWrite(wL2,wL1state);
digitalWrite(wL3,wL1state);
digitalWrite(wL4,wL1state);
digitalWrite(wL5,wL1state);
wLprevious = wLreading; // Set the previous reading of the White LED button to current reading
// Servo Button ----------------------------------------------------------------------------------------------------------------------------------
servoState = digitalRead(servoButton);
if (servoState == HIGH)
{
servo1.write(75);
}
else
{
servo1.write(0);
}
// Red LED'S breathing ----------------------------------------------------------------------------------------------------------------------------
analogWrite(rL1,brightness); // Write the set brightness to the red LED
brightness = brightness + fade; // Set new brightness to brightness value + fade value
if (brightness <= 0 || brightness >=255) // If brightness is less than 0 or more than 255
{
fade = -fade; // Negate the fade value, reversing the direction of the fade
}
delay(10); // Wait a short delay to see the fade
}```