From: Vladimir Garistov Date: Sat, 24 Oct 2020 22:00:51 +0000 (+0000) Subject: Renamed new files X-Git-Url: https://kolegite.com/gitweb/?a=commitdiff_plain;h=edba7e2e20d3488d50451fa0a560e412c8284a52;p=vmks.git Renamed new files --- diff --git a/LED_strip_2/LED_strip_2.ino b/LED_strip_2/LED_strip_2.ino deleted file mode 100644 index 77ba930..0000000 --- a/LED_strip_2/LED_strip_2.ino +++ /dev/null @@ -1,45 +0,0 @@ -#define BTN_PIN 2 -#define LED_PIN 13 - -void button_pressed_ISR(void); -void slow_computation(void); - -volatile uint8_t led_state = 0; - -void setup() -{ - pinMode(BTN_PIN, INPUT_PULLUP); - pinMode(LED_PIN, OUTPUT); - attachInterrupt(digitalPinToInterrupt(BTN_PIN), button_pressed_ISR, FALLING); - - Serial.begin(9600); -} - -void loop() -{ - slow_computation(); - - if (led_state) - Serial.println("LED in on."); - else - Serial.println("LED in off."); -} - -void button_pressed_ISR(void) -{ - if (led_state) - { - led_state = 0; - digitalWrite(LED_PIN, LOW); - } - else - { - led_state = 1; - digitalWrite(LED_PIN, HIGH); - } -} - -void slow_computation(void) -{ - delay(5000); -} \ No newline at end of file diff --git a/LED_strip_2/LED_strip_2.png b/LED_strip_2/LED_strip_2.png deleted file mode 100644 index 2d29e5c..0000000 Binary files a/LED_strip_2/LED_strip_2.png and /dev/null differ diff --git a/external_interrupt/external_interrupt.ino b/external_interrupt/external_interrupt.ino new file mode 100644 index 0000000..77ba930 --- /dev/null +++ b/external_interrupt/external_interrupt.ino @@ -0,0 +1,45 @@ +#define BTN_PIN 2 +#define LED_PIN 13 + +void button_pressed_ISR(void); +void slow_computation(void); + +volatile uint8_t led_state = 0; + +void setup() +{ + pinMode(BTN_PIN, INPUT_PULLUP); + pinMode(LED_PIN, OUTPUT); + attachInterrupt(digitalPinToInterrupt(BTN_PIN), button_pressed_ISR, FALLING); + + Serial.begin(9600); +} + +void loop() +{ + slow_computation(); + + if (led_state) + Serial.println("LED in on."); + else + Serial.println("LED in off."); +} + +void button_pressed_ISR(void) +{ + if (led_state) + { + led_state = 0; + digitalWrite(LED_PIN, LOW); + } + else + { + led_state = 1; + digitalWrite(LED_PIN, HIGH); + } +} + +void slow_computation(void) +{ + delay(5000); +} \ No newline at end of file diff --git a/external_interrupt/external_interrupt.png b/external_interrupt/external_interrupt.png new file mode 100644 index 0000000..2d29e5c Binary files /dev/null and b/external_interrupt/external_interrupt.png differ