/*
* Name: mod2_runLED.ino
* Date: 2021/10/14
* Author: fsc
* Version 1.0
* URL: https://wokwi.com/arduino/projects/312615861434188354
*/
const int LED1 = 4; //red
const int LED2 = 5; //green
const int LED3 = 6; //blue
const int LED4 = 7; //yellow
// aktuell aktive LED
int current = LED1;
// Starten der setup-Funktion, wird nur einmal aufgerufen
void setup()
{
// alle 4 Pin als Ausgang initialisieren
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
}
void loop()
{
digitalWrite(current, HIGH); // LED ein
delay(500);
digitalWrite(current, LOW); // LED aus
// zur nächsten LED wechseln
current = current + 1;
if (current > LED4)
current = LED1;
}
Comments