Arduino-compat attachInterrupt function error

If you are asking a question, please follow this template:

  1. My goal is: achieve interrupt deetction using arduino compat library
  2. My actions are: I wrote code in c as declared functions in arduino.h library
  3. The result I see is: implicit function declaration error
  4. My expectation & question is:
#include "mgos.h"
#include "Arduino.h"
uint8_t pin=25;
uint16_t milliseconds=0;

void handleInterrupt(){
	
	++milliseconds;
    if (milliseconds == 999)
	 { // roll over to zero
      milliseconds = 0; 
	   }
}
void interrupts() {   
   attachInterrupt(digitalPinToInterrupt(pin), handleInterrupt, FALLING);
}
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(2, OUTPUT);
  pinMode(pin, INPUT_PULLUP);
 // mgos_ints_enable();
    //pinMode(interruptPin, INPUT_PULLUP); 
   
 
}
// the loop function runs over and over again forever
void loop() {
  digitalWrite(2, HIGH); 
  delay(1000);                       // wait for a second
  digitalWrite(2, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);         
    println(milliseconds);
}

attachInterrupt is not implemented in the arduino-compat library.

Use mgos_gpio_set_int_handler

1 Like