mega2560- Interrupts reading digital input Hi I am very new to Arduino, with very little programming experience. 

I am using mega 2560 and trying to understand how interrupt works. 

I have a code written, it is very similar as the example code Memsic2125, so i am gonna use that in here.

For my case, I am reading from my hardware, 5x5 array of sensors. 

What I would like to do is to have it --   print out x and y using interrupts   , I want to print outputs the x and y every 10ms. Instead of printing it continuously right now.

I will be sending it out in 16 bits. I tried some other example and read a lot of material. but still couldn't get it to work. 

Any idea, suggestion, help, comment is appreciated.


const int xPin = 2;    
const int yPin = 3;

void setup() {

  Serial.begin(9600);
  pinMode(xPin, INPUT);
  pinMode(yPin, INPUT);
}

void loop() {

  int pulseX, pulseY;

  int x, y;

  // read pulse from x- and y-axes:
  pulseX = pulseIn(xPin, HIGH);
  pulseY = pulseIn(yPin, HIGH);


  x= ((pulseX / 10) - 500) * 8;
  y= ((pulseY / 10) - 500) * 8;

  // print x,y
  Serial.print("x,y= ( ");

  Serial.print(x);   Serial.print(,);
  Serial.print(y);   Serial.println(")");


  delay(100);
}
There isn't any interrupt code in what you posted. What exactly is the problem?  One important note is that you shouldn't try to print to Serial line in the interrupt handler as serial is itself driven from interrupts which are switched off during your handler code.  If all you really want to do is to print something every 10ms then you don't need any interrupt.  Just use the "Blink Without Delay" style of timing and keep the other code from blocking.