🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    difficulty to generate interrupt signal with G26 on M5StickC Plus

    Arduino
    2
    2
    2.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Marco.Cantoni
      last edited by

      I feel embarrassed to ask for such a stupid issue:
      I cannot get a simple button attached to G26 (pressed: G26->GND) generate an interrupt and light up the on board LED. With digitalRead it works. I want to use the interrupt version to read pwm signals eventually.
      I am using Arduino-IDE.

      Here is my code:

      #include <M5StickCPlus.h>
      /* pin that is attached to interrupt */
      uint8_t interruptPin = 26;

      void pressed() {
      digitalWrite(10, LOW); // LED on
      delay(100);
      digitalWrite(10,HIGH); // LED off
      }

      void setup() {
      // when pin G26 goes low, call the pressed function
      pinMode(interruptPin,INPUT_PULLUP);
      attachInterrupt(digitalPinToInterrupt(interruptPin), pressed, LOW);
      pinMode(10,OUTPUT);
      digitalWrite(10, HIGH); // LED off to start with
      }

      void loop() {
      // put your main code here, to run repeatedly:
      }

      1 Reply Last reply Reply Quote 0
      • felmueF
        felmue
        last edited by

        Hello @Marco-Cantoni

        try FALLING instead of LOW when calling attachInterrupt().

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        1 Reply Last reply Reply Quote 0
        • First post
          Last post