Skip to content

attachInterrupt with pin "LOGO" doesn't work (Micro:bit V2) #445

Open
@Polyphe

Description

@Polyphe

Hello,
with the code here below "attachInterrupt(digitalPinToInterrupt(LOGO), doIntLOGO, FALLING);" that didn't work, with
attachInterrupt(digitalPinToInterrupt(BUTTONA), doIntLOGO, FALLING); that worked (???). Why ?

#define BUTTONA   (5) 
#define BUTTONB   (11)

#define LOGO      (26)
#define RUN_MIC   (28)

int toggle=1;

void gpio_init(void)
{
  pinMode(BUTTONA, INPUT);  
  pinMode(BUTTONB, INPUT);
  pinMode(LOGO, INPUT);
  
  digitalWrite(RUN_MIC, LOW);
  pinMode(RUN_MIC, OUTPUT);
}

// initialise interrupt
//
void int_init(){
  attachInterrupt(digitalPinToInterrupt(LOGO), doIntLOGO, FALLING);
}

// LOGO handler (input select)
//
void doIntLOGO(){
  if(toggle<0){
    digitalWrite(RUN_MIC, LOW); // disable microphone
    toggle=1;
  }else{
    digitalWrite(RUN_MIC, HIGH); // enable microphone
    toggle=-1;
  }
}


void setup() {
  // put your setup code here, to run once:
  gpio_init();
  int_init();
}

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions