Trying to test the attach interrupt function in the ArduinoIDE and on teensy3. This compiles and loads with the teensyduino beta6. I have a wire between 13 and 0 and I get no pulses counted in the ISR. The loop counts and runs, I see the pulse_train going 1 and 0 and the led is flashing. I assume I am doing something wrong. I use similar code in a breadboard with a Mega and count pulses from a pump and it works flawlessly. I am investigating moving this to a Teensy3 and wanted to investigate this function. I assume I am doing something wrong. Why do I get no ISR service?
Code:
/* sketch to verify external interrupt...
*/
#include <LiquidCrystal_I2C.h>
#include <Wire.h> // needed for i2c display
LiquidCrystal_I2C lcd(0x20);
int pulse_out = 13; // pulses out on 13
int int_input = 0; // interrupt on 0
int count;
int loop_num = 0;
float dispensed = 0; // dispensed volume
boolean pulse_train = false;
void setup()
{
// set up display
lcd.begin(16,2);
lcd.clear();
// set up pins in and out
pinMode(pulse_out,OUTPUT);
attachInterrupt(int_input, counterloop, FALLING); // pin 0 pulses input
}
void loop()
{
dispensed = count;
lcd.setCursor(0,0);
lcd.print(dispensed,0);
// flop the output and boolean var each time through loop
if (pulse_train == true) {
digitalWrite(pulse_out,false);
pulse_train = false; }
else {digitalWrite(pulse_out,true);
pulse_train = true; }
lcd.setCursor(0,1);
lcd.print(pulse_train);
loop_num++;
lcd.setCursor(5,0);
lcd.print(loop_num);
delay(1000);
}
// ISRs for counting fluid transfer
void counterloop() { // loop to totalize
count = count + 1; }