// Circuit adapted:
// ----------------
// Pin A6 and A7 can not be used as digital switches.
// Wokwi can not simulate analog signals yet.

const int pinLDR = A7;
const int pinSwitches[3] = { A2, A3};
const int pinLeds[16] = {13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, A0, A1, A4, A5};

int speed;         // delay in ms

void setup() 
{
  Serial.begin( 9600);
  Serial.println( "The sketch has started");

  for( auto a:pinLeds)
  {
    pinMode( a, OUTPUT);
  }
}

void loop() 
{
  int value = analogRead( pinLDR);
  speed = 50 - (value / 25);
  
  bool S2, S3;

  if( digitalRead( pinSwitches[0]) == HIGH)
    S2 = true;
  else
    S2 = false;

  if( digitalRead( pinSwitches[1]) == HIGH)
    S3 = true;
  else
    S3 = false;

  if( S2 and not S3)
  {
    Serial.println( "Switch S2");
    einAblauf();
  }
  else if( S3 and not S2)
  {
    Serial.println( "Switch S3");
    scrollLeft();
  }
  else if( S2 and S3)
  {
    Serial.println( "Beide");
    alternate();
  }
}

void einAblauf()
{
  for( auto a:pinLeds)
  {
    digitalWrite( a, HIGH);
    delay( speed);
    digitalWrite( a, LOW);
    delay( speed);
  }
}

void scrollLeft()
{
  for( int i=15; i>=0; i--)
  {
    digitalWrite( pinLeds[i], HIGH);
    delay( speed);
    digitalWrite( pinLeds[i], LOW);
    delay( speed);
  }
}

void alternate()
{
  for( int i=0; i<16; i+=2)
  {
    digitalWrite( pinLeds[i], HIGH);
  }
  delay( speed);
  for( int i=0; i<16; i+=2)
  {
    digitalWrite( pinLeds[i], LOW);
  }
  delay( speed);
  for( int i=1; i<16; i+=2)
  {
    digitalWrite( pinLeds[i], HIGH);
  }
  delay( speed);
  for( int i=1; i<16; i+=2)
  {
    digitalWrite( pinLeds[i], LOW);
  }
  delay( speed);
}