Arduino Micro External Interrupts Problem

Hi There,

I have a fair amount of experience in programming pics and various other micro controllers but have recently invested in an Arduino Micro for the relatively simple task of reading a RC receiver output.

So far I have been unsuccessful in not only reading the receiver but even in getting a basic external interrupt to fire on any change of the pins laid out on the boards reference page. These are given as Pin 0,1,2,3 presuming one is not using the Serial or I2C.

I have read similar problems with the Leonardo that uses the same micro processor as the Micro. Making the proposed changes to the pin_headers.h and Winterrupts.c file seemed to make no difference. There appears to be very limited information on the Micro board online, that me be because its title makes for a very convoluted google search.

For the purpose of testing I have written two basic programs. The first makes use of polling and works perfectly given my simple circuit of a switch and pull down resistor. The second attempts to use interrupts that never appear to fire.

//Uses Polling
int pin = 11;
volatile int state = LOW;

void setup()
{
  pinMode(pin, OUTPUT);
  pinMode(2,INPUT);
  digitalWrite(2, 1); // pull up on
  Serial.begin(9600);
}

void loop()
{
  digitalWrite(pin, state);
  Serial.println(state);
  delay(1000);
  state=digitalRead(2);
}

This is the interrupt routine which does not appear to work

int pin = 11;
int InPin=2;
volatile int state = LOW;

void setup()
{
  pinMode(pin, OUTPUT);
  pinMode(InPin,INPUT);
  digitalWrite(InPin, 1); // pull up on
  attachInterrupt(InPin,blink,CHANGE);

}

void loop()
{
  digitalWrite(pin, state);
}

void blink()
{
  state = !state;
}

Any help with this problem would be much appreciated as I have spent a good few days on it. If it is not possible for what ever reason could Arduino please change the documentation.

Unless I am missing something, you are not using attachInterrupts ?

I have a lot of tried and test RC Reading code at rcarduino.blogspot.com you could use this as a starting point

Duane B

rcarduino.blogspot.com

Appologies,that line must have been deleted at some stage. The revised code still does not work. However, changing the Attachinterrupt to:

attachInterrupt(1,blink,CHANGE);

Seems to have resolved the problem.

Thanks for you help and i will check out that website.

Regards