From ccaa8c7c9e0081a17de075acb386498fd0c7bd5c Mon Sep 17 00:00:00 2001 From: Mohsen Heidari Date: Thu, 2 Jul 2026 18:30:31 +0330 Subject: [PATCH] Make the Interrupt. --- src/main.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index fd616ad..8453716 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,15 +1,31 @@ #include -#define BUZZER 3 +#define LED 13 + +void displayMicros(); +void displayMillis(); // Setup Section void setup() { - pinMode(BUZZER, OUTPUT); + Serial.begin(9600); + pinMode(LED, OUTPUT); + attachInterrupt(0, displayMicros, RISING); // #1 + attachInterrupt(1, displayMillis, RISING); +} + +void displayMicros() { + Serial.write("micros() = "); + Serial.println(micros()); +} + +void displayMillis() { + Serial.write("millis() = "); + Serial.println(millis()); } // Loop Section void loop() { - analogWrite(BUZZER, 500); + digitalWrite(LED, HIGH); delay(500); - digitalWrite(BUZZER, LOW); + digitalWrite(LED, LOW); delay(500); }