Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define interruptPin D5
- volatile bool interruptDetected = false;
- int interruptCount = 0;
- long oldMillis = 0;
- void setup() {
- Serial.begin(115200);
- Serial.println("\nStart");
- pinMode(interruptPin, INPUT_PULLUP);
- attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, RISING);
- }
- void handleInterrupt() {
- interruptDetected = true;
- }
- void loop() {
- /*if (oldMillis == 0 || (millis() - oldMillis > 1000)) { //sekündliche Ausgabe des Pin-Levels
- oldMillis = millis();
- Serial.println("state = "+digitalRead(interruptPin) ? "H":"L");
- }*/
- if (interruptDetected) {
- interruptDetected = false;
- interruptCount++;
- Serial.print("Interrupt erkannt! Gesamt: ");
- Serial.println(interruptCount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement