Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, an initiative of Stroud Water Research Center designed to help people advance knowledge and stewardship of fresh water.
New to EnviroDIY? Start here

Reply To: Interrupt

Home Forums Mayfly Data Logger Interrupt Reply To: Interrupt

#2226
Shannon Hicks
Moderator

    The Mayfly has 3 hardware interrupts. They are RXD1 (INT0), TXD1 (INT1), and D10 (INT2). To use the “attachInterrupt” function, you can only use the three hardware interrupt pins, and you have to refer to them as “0”, “1”, or “2”. So if you want to use the D10 interrupt pin, you’ll need to say the following on line 8:

    attachInterrupt(2, countUp, CHANGE);

    You also don’t have to define the interrupt pin in line 1 of your above code, or set the pinMode in line 7, so remove both of those lines.

    Depending on what hall effect sensor you’re using, you’ll probably need to use a pullup resistor on the output of the sensor. If you’re using the Mayfly v0.5, you can use the optional onboard pullup resistor for D10 by closing SJ12, meaning you can measure a switch like the hall effect sensor as an interrupt with no additional parts.