interrupt

somebody know, how i can use the attachinterrupt(pin, code interrupt, low) because, i can not declare the another function that i made. inside the code interrupt.

void setup (){
Wire.begin(); //iniciar el bus de I2C
Serial.begin(9600);
pinMode(INTERRUPTPIN, INPUT);
initGyro();
sei();
attachInterrupt(0,interruptfinal,LOW);

}

void interruptfinal() {

byte aux=readByte(GYRO, G_INT_STATUS);
if (aux==00000001 || aux==00000101){

readFrom(GYRO, G_INT_STATUS, 8, gyro);
x = ((gyro[2] << 8) | gyro[3]);
y = ((gyro[4] << 8) | gyro[5]);
z = ((gyro[6] << 8) | gyro[7]);
temp = (gyro[0] << 8) | gyro[1];

}

void readFrom(int device, byte address, int num, byte buff) {
Wire.beginTransmission(device);
Wire.send(address);
Wire.endTransmission();

//RESTART CONDITION
Wire.beginTransmission(device);
Wire.requestFrom(device, num);

int i = 0;
while(Wire.available())
{
buff *= Wire.receive(); *

  • i++;*
  • }*
  • Wire.endTransmission(); *
    }

There's a few obvious problems with the code you pasted, so I'm not sure if you've left bits out on purpose...?

You don't declare your x, y, z, or temp variables in the ISR for starters, and if they're global they need to be declared as volatile. I'd be setting a simple flag and getting out of the ISR as soon as possible, then do your reads etc in the main loop after checking if your flag has been toggled.

What's the exact error you get from the compiler?

Cheers,