//Created by Barbu Vulc!
//Pushbutton, switch & 8 LEDs
const int b = A0;  const int Switch = 2;
int switchState = 0; //Variable for reading the slide switch status!
byte leds[] = {5, 6, 7, 8, 9, 10, 11, 12};

void setLeds(long pattern){
  for(int k=0; k<sizeof(leds); k++){
    digitalWrite(leds[k], pattern & 1);
    pattern = pattern >> 1;
  }
}

//LEDs, slide switch & pushbutton initalization
void setup(){
  pinMode(Switch, INPUT);  pinMode(b,INPUT);
  for(int k=0; k<sizeof(leds); k++){pinMode(leds[k], OUTPUT);}
}

//Control of the LEDs
/*If slide switch is turned on => 
    either: 
    button = 0 => 
    black->gray->silver->white->yellow->gold->orange->red! 
    Or 
    button = 1 => 
    red->orange->gold->yellow->white->silver->gray->black!
  But if slide switch is turned off =>
    red->orange->gold->yellow and
    black->gray->silver->white simultaneously!*/
void loop(){
  //The slide switch!
  switchState = digitalRead(Switch);
  //Put into switch state (better than if-else, in this case)!
  bool bst = digitalRead(b);  byte state = bst;
  
  if(switchState == HIGH){
    setLeds(0b10000001);
    delay(256);
    setLeds(0b01000010);
    delay(256);
    setLeds(0b00100100);
    delay(256);
    setLeds(0b00011000);
    delay(256);
    setLeds(0b00100100);
    delay(256);
    setLeds(0b01000010);
    delay(256);
  }else{
    switch(state){
    case 0: 
      setLeds(0b10000000);
      delay(100);
      setLeds(0b01000000);
      delay(100);
      setLeds(0b00100000);
      delay(100);
      setLeds(0b00010000);
      delay(100);
      setLeds(0b00001000);
      delay(100);
      setLeds(0b00000100);
      delay(100);
      setLeds(0b00000010);
      delay(100);
      setLeds(0b00000001);
      delay(100);
    break;

    case 1: 
      setLeds(0b00000001);
      delay(100);
      setLeds(0b00000010);
      delay(100);
      setLeds(0b00000100);
      delay(100);
      setLeds(0b00001000);
      delay(100);
      setLeds(0b00010000);
      delay(100);
      setLeds(0b00100000);
      delay(100);
      setLeds(0b01000000);
      delay(100);
      setLeds(0b10000000);
      delay(100);
    break;
    }
  }
}
$abcdeabcde151015202530354045505560fghijfghij