Zum Inhalt springen

Antwort auf: Schulprojekt_Frage

#6545
Lukas Bachinger
Teilnehmer

const int inputPin = 2;
const int outputPin = 10;

volatile int state=1;
volatile unsigned long lastTime=0;

void setup() {
pinMode(inputPin, INPUT);

attachInterrupt(digitalPinToInterrupt(10), signal, RISING);
}

void signal(){
unsigned long now = millis();
if (now – lastTime > 300){
state++;
if (state > 3){state=1;}
}
lastTime=now;
}

void loop(){
int fadeValue = 3;
digitalWrite(outputPin, fadeValue);
delay(1000);
}

Dies ist mein bisheriges Programm, leider funktioniert es noch nicht so wie es soll.