Arduino: Übung Blinkrhythmus

Aufgabenstellung:

Eine LED blinkt zuerst im 2 Sekunden Rhythmus. Bei jedem Zyklus soll die LED 200ms schneller blinken. Dies bis die LED fix leuchtet.

Lösung:

const int LEDPIN = 8;

void setup() {
// initialisiert PIN 8 als output
pinMode(LEDPIN,OUTPUT);

}

void loop() {
int delayRhythmus = 2000;
while(delayRhythmus >= 0)
{
digitalWrite(LEDPIN, HIGH);
delay(delayRhythmus);
digitalWrite(LEDPIN,LOW);
delayRhythmus -= 200;
}
}