// Definitionen
#define LED9 5
#define LED8 6
#define LED7 7
#define LED6 15
#define LED5 16
#define LED4 17
#define LED3 18
#define LED2 8
#define LED1 3

#define GNDPIN12 12
#define GNDPIN13 13
#define GNDPIN14 14

int arraytest[] = {LED9, LED8, LED7, LED6, LED5, LED4, LED3, LED2, LED1};


void setup() {
  // put your setup code here, to run once:
  pinMode(GNDPIN12, OUTPUT);
  pinMode(GNDPIN13, OUTPUT);
  pinMode(GNDPIN14, OUTPUT);

  pinMode(LED9, OUTPUT);
  pinMode(LED8, OUTPUT);
  pinMode(LED7, OUTPUT);
  pinMode(LED6, OUTPUT);
  pinMode(LED5, OUTPUT);
  pinMode(LED4, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED1, OUTPUT);


  Serial.begin(115200);
  Serial.println("Hello, ESP32-S3!");
}


void loop() {
  schichtenSchalten(1);


}


void schichtenSchalten(int schichtzahl) {
  
  if (schichtzahl == 1) {
    digitalWrite(GNDPIN12, LOW); //Schicht 1
    digitalWrite(GNDPIN13, HIGH); //Schicht 2
    digitalWrite(GNDPIN14, HIGH); //Schicht 3
  } else if (schichtzahl == 2) {
    digitalWrite(GNDPIN12, HIGH); //Schicht 1
    digitalWrite(GNDPIN13, LOW); //Schicht 2
    digitalWrite(GNDPIN14, HIGH); //Schicht 3
  } else if (schichtzahl == 3) {
    digitalWrite(GNDPIN12, HIGH); //Schicht 1
    digitalWrite(GNDPIN13, HIGH); //Schicht 2
    digitalWrite(GNDPIN14, LOW); //Schicht 3
  }

  // LED An/aus
  for (int i = 0; i < 9; i++) {
    digitalWrite(arraytest[i], HIGH);
    digitalWrite(arraytest[i-1],LOW);
    
    Serial.print("An ");
    Serial.println(i);
    delay(100);
    if (i == 8) {
      digitalWrite(arraytest[i],LOW);
    }
  }
}
Loading
esp32-s3-devkitc-1