Black Lives Matter - Action and Equality. ... Adafruit joins the Stop Hate for Profit campaign.

help Using interrupts on feather m0's
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

help Using interrupts on feather m0's

by nitrousbob on Thu Jun 13, 2019 1:07 pm

I have a sketch i used with an UNO, I was able to easily read up to 32k rpms from a function generator

Code: Select all | TOGGLE FULL SIZE
float rev = 0;                                       // Inital Case for Motor (Stop)
int rpm;                                             // Revoluation per minute, unit of speed measuring as integer
int oldtime = 0;                                     // Starting
int timey;                                            // Save time as integer

void isr () {                                        // Interrupt service routine
  rev ++;

void setup() {
  pinMode(2, INPUT);
    attachInterrupt(digitalPinToInterrupt(2), isr, RISING); // Attaching the interrupt (recommended)

void loop() {
  detachInterrupt(digitalPinToInterrupt(2));          // Detaches the interrupt
  timey=millis()-oldtime;                             // Finds the time
  rpm=(rev/timey)*1000;                              // Calculates RPM used to be 60000
  oldtime=millis();                                  // Saves the current time
  Serial.print(" RPM");

I tried to change all the 2's to a 5 to use Digital Pin 5 on the M0 and I cannot get it to work. Is there something else to get the interrupts to work on a Feather?

I also realized later that the function generator was probably putting out 5v, possibly, so im going to get a level shifter put in for the input to pin 5

Posts: 13
Joined: Sun Mar 11, 2018 1:43 pm

Please be positive and constructive with your questions and comments.